summaryrefslogtreecommitdiff
path: root/sd/source/ui/view
diff options
context:
space:
mode:
Diffstat (limited to 'sd/source/ui/view')
-rwxr-xr-xsd/source/ui/view/DocumentRenderer.cxx2422
-rwxr-xr-xsd/source/ui/view/DocumentRenderer.hrc62
-rwxr-xr-xsd/source/ui/view/DocumentRenderer.src202
-rw-r--r--sd/source/ui/view/FormShellManager.cxx393
-rwxr-xr-xsd/source/ui/view/GraphicObjectBar.cxx185
-rwxr-xr-xsd/source/ui/view/GraphicViewShellBase.cxx132
-rwxr-xr-xsd/source/ui/view/ImpressViewShellBase.cxx122
-rwxr-xr-xsd/source/ui/view/MediaObjectBar.cxx166
-rwxr-xr-xsd/source/ui/view/OutlineViewShellBase.cxx86
-rwxr-xr-xsd/source/ui/view/Outliner.cxx1828
-rwxr-xr-xsd/source/ui/view/OutlinerIterator.cxx898
-rwxr-xr-xsd/source/ui/view/PresentationViewShellBase.cxx123
-rwxr-xr-xsd/source/ui/view/SlideSorterViewShellBase.cxx97
-rwxr-xr-xsd/source/ui/view/ToolBarManager.cxx1697
-rw-r--r--sd/source/ui/view/UpdateLockManager.cxx429
-rwxr-xr-xsd/source/ui/view/ViewClipboard.cxx278
-rw-r--r--sd/source/ui/view/ViewShellBase.cxx1735
-rw-r--r--sd/source/ui/view/ViewShellHint.cxx52
-rwxr-xr-xsd/source/ui/view/ViewShellImplementation.cxx449
-rwxr-xr-xsd/source/ui/view/ViewShellManager.cxx1467
-rwxr-xr-xsd/source/ui/view/ViewTabBar.cxx716
-rw-r--r--sd/source/ui/view/WindowUpdater.cxx189
-rwxr-xr-xsd/source/ui/view/bmcache.cxx78
-rw-r--r--sd/source/ui/view/clview.cxx107
-rwxr-xr-xsd/source/ui/view/drawview.cxx651
-rwxr-xr-xsd/source/ui/view/drbezob.cxx365
-rwxr-xr-xsd/source/ui/view/drtxtob.cxx591
-rwxr-xr-xsd/source/ui/view/drtxtob1.cxx612
-rwxr-xr-xsd/source/ui/view/drviews1.cxx1449
-rwxr-xr-xsd/source/ui/view/drviews2.cxx976
-rwxr-xr-xsd/source/ui/view/drviews3.cxx950
-rwxr-xr-xsd/source/ui/view/drviews4.cxx1007
-rwxr-xr-xsd/source/ui/view/drviews5.cxx746
-rwxr-xr-xsd/source/ui/view/drviews6.cxx742
-rwxr-xr-xsd/source/ui/view/drviews7.cxx1741
-rwxr-xr-xsd/source/ui/view/drviews8.cxx557
-rwxr-xr-xsd/source/ui/view/drviews9.cxx881
-rwxr-xr-xsd/source/ui/view/drviewsa.cxx860
-rwxr-xr-xsd/source/ui/view/drviewsb.cxx879
-rwxr-xr-xsd/source/ui/view/drviewsc.cxx990
-rwxr-xr-xsd/source/ui/view/drviewsd.cxx259
-rwxr-xr-xsd/source/ui/view/drviewse.cxx1694
-rwxr-xr-xsd/source/ui/view/drviewsf.cxx576
-rwxr-xr-xsd/source/ui/view/drviewsg.cxx296
-rwxr-xr-xsd/source/ui/view/drviewsh.cxx193
-rwxr-xr-xsd/source/ui/view/drviewsi.cxx207
-rwxr-xr-xsd/source/ui/view/drviewsj.cxx564
-rwxr-xr-xsd/source/ui/view/drvwshrg.cxx127
-rwxr-xr-xsd/source/ui/view/frmview.cxx1214
-rwxr-xr-xsd/source/ui/view/grviewsh.cxx156
-rw-r--r--sd/source/ui/view/makefile.mk123
-rwxr-xr-xsd/source/ui/view/outlnvs2.cxx648
-rwxr-xr-xsd/source/ui/view/outlnvsh.cxx2165
-rwxr-xr-xsd/source/ui/view/outlview.cxx2181
-rwxr-xr-xsd/source/ui/view/presvish.cxx188
-rwxr-xr-xsd/source/ui/view/sdruler.cxx226
-rwxr-xr-xsd/source/ui/view/sdview.cxx1316
-rwxr-xr-xsd/source/ui/view/sdview2.cxx1038
-rwxr-xr-xsd/source/ui/view/sdview3.cxx1506
-rwxr-xr-xsd/source/ui/view/sdview4.cxx638
-rwxr-xr-xsd/source/ui/view/sdview5.cxx114
-rwxr-xr-xsd/source/ui/view/sdwindow.cxx1210
-rwxr-xr-xsd/source/ui/view/tabcontr.cxx464
-rwxr-xr-xsd/source/ui/view/unmodpg.cxx247
-rwxr-xr-xsd/source/ui/view/viewoverlaymanager.cxx619
-rwxr-xr-xsd/source/ui/view/viewshe2.cxx1213
-rw-r--r--sd/source/ui/view/viewshe3.cxx448
-rwxr-xr-xsd/source/ui/view/viewshel.cxx1636
-rwxr-xr-xsd/source/ui/view/zoomlist.cxx197
69 files changed, 49373 insertions, 0 deletions
diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx
new file mode 100755
index 000000000000..7f67a549fc10
--- /dev/null
+++ b/sd/source/ui/view/DocumentRenderer.cxx
@@ -0,0 +1,2422 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include "DocumentRenderer.hxx"
+#include "DocumentRenderer.hrc"
+
+#include "drawdoc.hxx"
+#include "optsitem.hxx"
+#include "sdresid.hxx"
+#include "strings.hrc"
+#include "sdattr.hxx"
+#include "Window.hxx"
+#include "drawview.hxx"
+#include "DrawViewShell.hxx"
+#include "FrameView.hxx"
+#include "Outliner.hxx"
+#include "OutlineViewShell.hxx"
+
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <sfx2/printer.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdopage.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/xlnclit.hxx>
+#include <toolkit/awt/vclxdevice.hxx>
+#include <tools/resary.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/moduleoptions.hxx>
+
+#include <vector>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+
+namespace sd {
+
+namespace {
+ OUString A2S (const char* pString)
+ {
+ return OUString::createFromAscii(pString);
+ }
+
+
+
+ /** Convenience class to extract values from the sequence of properties
+ given to one of the XRenderable methods.
+ */
+ class PrintOptions
+ {
+ public:
+ PrintOptions (
+ const vcl::PrinterOptionsHelper& rHelper,
+ const ::std::vector<sal_Int32>& rSlidesPerPage)
+ : mrProperties(rHelper),
+ maSlidesPerPage(rSlidesPerPage)
+ {
+ }
+
+ bool IsWarningOrientation (void) const
+ {
+ return GetBoolValue(NULL, true);
+ }
+
+ bool IsPrintPageName (void) const
+ {
+ return GetBoolValue("IsPrintName");
+ }
+
+ bool IsDate (void) const
+ {
+ return GetBoolValue("IsPrintDateTime");
+ }
+
+ bool IsTime (void) const
+ {
+ return GetBoolValue("IsPrintDateTime");
+ }
+
+ bool IsHiddenPages (void) const
+ {
+ return GetBoolValue("IsPrintHidden");
+ }
+
+ bool IsHandoutHorizontal (void) const
+ {
+ return GetBoolValue("SlidesPerPageOrder", sal_Int32(0), true);
+ }
+
+ sal_Int32 GetHandoutPageCount (void) const
+ {
+ sal_uInt32 nIndex = static_cast<sal_Int32>(mrProperties.getIntValue("SlidesPerPage", sal_Int32(0)));
+ if (nIndex<maSlidesPerPage.size())
+ return maSlidesPerPage[nIndex];
+ else if ( ! maSlidesPerPage.empty())
+ return maSlidesPerPage[0];
+ else
+ return 0;
+ }
+
+ bool IsDraw (void) const
+ {
+ return GetBoolValue("PageContentType", sal_Int32(0));
+ }
+
+ bool IsHandout (void) const
+ {
+ return GetBoolValue("PageContentType", sal_Int32(1));
+ }
+
+ bool IsNotes (void) const
+ {
+ return GetBoolValue("PageContentType", sal_Int32(2));
+ }
+
+ bool IsOutline (void) const
+ {
+ return GetBoolValue("PageContentType", sal_Int32(3));
+ }
+
+ sal_uLong GetOutputQuality (void) const
+ {
+ sal_Int32 nQuality = static_cast<sal_Int32>(mrProperties.getIntValue( "Quality", sal_Int32(0) ));
+ return nQuality;
+ }
+
+ bool IsPageSize (void) const
+ {
+ return GetBoolValue("PageOptions", sal_Int32(1));
+ }
+
+ bool IsTilePage (void) const
+ {
+ return GetBoolValue("PageOptions", sal_Int32(2)) || GetBoolValue("PageOptions", sal_Int32(3));
+ }
+
+ bool IsCutPage (void) const
+ {
+ return GetBoolValue("PageOptions", sal_Int32(0));
+ }
+
+ bool IsBooklet (void) const
+ {
+ return GetBoolValue("PrintProspect", false);
+ }
+
+ bool IsPrintExcluded (void) const
+ {
+ return (IsNotes() || IsDraw() || IsHandout()) && IsHiddenPages();
+ }
+
+ bool IsPrintFrontPage (void) const
+ {
+ sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintProspectInclude", 0 ));
+ return nInclude == 0 || nInclude == 1;
+ }
+
+ bool IsPrintBackPage (void) const
+ {
+ sal_Int32 nInclude = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintProspectInclude", 0 ));
+ return nInclude == 0 || nInclude == 2;
+ }
+
+ bool IsPaperBin (void) const
+ {
+ return GetBoolValue("PrintPaperFromSetup", false);
+ }
+
+ OUString GetPrinterSelection (void) const
+ {
+ sal_Int32 nContent = static_cast<sal_Int32>(mrProperties.getIntValue( "PrintContent", 0 ));
+ OUString sValue( A2S("all") );
+ if( nContent == 1 )
+ sValue = mrProperties.getStringValue( "PageRange", A2S( "all" ) );
+ else if( nContent == 2 )
+ sValue = A2S( "selection" );
+ return sValue;
+ }
+
+ private:
+ const vcl::PrinterOptionsHelper& mrProperties;
+ const ::std::vector<sal_Int32> maSlidesPerPage;
+
+ /** When the value of the property with name pName is a boolean then
+ return its value. When the property is unknown then
+ bDefaultValue is returned. Otherwise <FALSE/> is returned.
+ */
+ bool GetBoolValue (
+ const sal_Char* pName,
+ const bool bDefaultValue = false) const
+ {
+ sal_Bool bValue = mrProperties.getBoolValue( pName, bDefaultValue );
+ return bValue;
+ }
+
+ /** Return <TRUE/> when the value of the property with name pName is
+ a string and its value equals pValue. When the property is
+ unknown then bDefaultValue is returned. Otherwise <FALSE/> is
+ returned.
+ */
+ bool GetBoolValue (
+ const sal_Char* pName,
+ const sal_Char* pValue,
+ const bool bDefaultValue = false) const
+ {
+ OUString sValue( mrProperties.getStringValue( pName ) );
+ if (sValue.getLength())
+ return sValue.equalsAscii(pValue);
+ else
+ return bDefaultValue;
+ }
+
+ /** Return <TRUE/> when the value of the property with name pName is
+ an integer and its value is nTriggerValue. Otherwise <FALSE/> is
+ returned.
+ */
+ bool GetBoolValue (
+ const sal_Char* pName,
+ const sal_Int32 nTriggerValue) const
+ {
+ sal_Int32 nValue = static_cast<sal_Int32>(mrProperties.getIntValue( pName ));
+ return nValue == nTriggerValue;
+ }
+ };
+
+
+
+ /** This class is like MultiSelection but understands two special values.
+ "all" indicates that all pages are selected. "selection" indicates that no
+ pages but a set of shapes is selected.
+ */
+ class Selection
+ {
+ public:
+ Selection (const OUString& rsSelection, const SdPage* pCurrentPage)
+ : mbAreAllPagesSelected(rsSelection.equalsAscii("all")),
+ mbIsShapeSelection(rsSelection.equalsAscii("selection")),
+ mnCurrentPageIndex(pCurrentPage!=NULL ? (pCurrentPage->GetPageNum()-1)/2 : -1),
+ mpSelectedPages()
+ {
+ if ( ! (mbAreAllPagesSelected || mbIsShapeSelection))
+ mpSelectedPages.reset(new MultiSelection(rsSelection));
+ }
+
+ bool IsMarkedOnly (void) const
+ {
+ return mbIsShapeSelection;
+ }
+
+ /** Call with a 0 based page index.
+ */
+ bool IsSelected (const sal_Int32 nIndex) const
+ {
+ if (mbAreAllPagesSelected)
+ return true;
+ else if (mpSelectedPages)
+ return mpSelectedPages->IsSelected(nIndex+1);
+ else if (mbIsShapeSelection && nIndex==mnCurrentPageIndex)
+ return true;
+ else
+ return false;
+ }
+
+ private:
+ const bool mbAreAllPagesSelected;
+ const bool mbIsShapeSelection;
+ const sal_Int32 mnCurrentPageIndex;
+ ::boost::scoped_ptr<MultiSelection> mpSelectedPages;
+ };
+
+ /** A collection of values that helps to reduce the number of arguments
+ given to some functions. Note that not all values are set at the
+ same time.
+ */
+ class PrintInfo
+ {
+ public:
+ PrintInfo (
+ const Printer* pPrinter,
+ const OUString& rsPrinterSelection,
+ const ::boost::shared_ptr<ViewShell> pView)
+ : mpPrinter(pPrinter),
+ mnDrawMode(DRAWMODE_DEFAULT),
+ msTimeDate(),
+ msPageString(),
+ maPrintSize(0,0),
+ maPageSize(0,0),
+ meOrientation(ORIENTATION_PORTRAIT),
+ maMap(),
+ maSelection(rsPrinterSelection, pView ? pView->getCurrentPage() : NULL),
+ mbPrintMarkedOnly(maSelection.IsMarkedOnly())
+ {}
+
+ const Printer* mpPrinter;
+ sal_uLong mnDrawMode;
+ ::rtl::OUString msTimeDate;
+ ::rtl::OUString msPageString;
+ Size maPrintSize;
+ Size maPageSize;
+ Orientation meOrientation;
+ MapMode maMap;
+ const Selection maSelection;
+ bool mbPrintMarkedOnly;
+ };
+
+
+
+ /** Output one page of the document to the given printer. Note that
+ more than one document page may be output to one printer page.
+ */
+ void PrintPage (
+ Printer& rPrinter,
+ ::sd::View& rPrintView,
+ SdPage& rPage,
+ View* pView,
+ const bool bPrintMarkedOnly,
+ const SetOfByte& rVisibleLayers,
+ const SetOfByte& rPrintableLayers)
+ {
+ rPrintView.ShowSdrPage(&rPage);
+
+ const MapMode aOriginalMapMode (rPrinter.GetMapMode());
+
+ // Set the visible layers
+ SdrPageView* pPageView = rPrintView.GetSdrPageView();
+ OSL_ASSERT(pPageView!=NULL);
+ pPageView->SetVisibleLayers(rVisibleLayers);
+ pPageView->SetPrintableLayers(rPrintableLayers);
+
+ if (pView!=NULL && bPrintMarkedOnly)
+ pView->DrawMarkedObj(rPrinter);
+ else
+ rPrintView.CompleteRedraw(&rPrinter, Rectangle(Point(0,0), rPage.GetSize()));
+
+ rPrinter.SetMapMode(aOriginalMapMode);
+
+ rPrintView.HideSdrPage();
+ }
+
+
+
+
+ /** Output a string (that typically is not part of a document page) to
+ the given printer.
+ */
+ void PrintMessage (
+ Printer& rPrinter,
+ const ::rtl::OUString& rsPageString,
+ const Point& rPageStringOffset)
+ {
+ const Font aOriginalFont (rPrinter.OutputDevice::GetFont());
+ rPrinter.SetFont(Font(FAMILY_SWISS, Size(0, 423)));
+ rPrinter.DrawText(rPageStringOffset, rsPageString);
+ rPrinter.SetFont(aOriginalFont);
+ }
+
+
+
+
+ /** Read the resource file and process it into a sequence of properties
+ that can be passed to the printing dialog.
+ */
+ class DialogCreator : Resource
+ {
+ public:
+ DialogCreator (bool bImpress)
+ : Resource(SdResId(_STR_IMPRESS_PRINT_UI_OPTIONS))
+ , mbImpress(bImpress)
+ {
+ ProcessResource();
+ }
+
+ Sequence< beans::PropertyValue > GetDialogControls(void) const
+ {
+ if (maProperties.empty())
+ return Sequence< beans::PropertyValue >();
+ else
+ {
+ return Sequence<beans::PropertyValue>(
+ &maProperties.front(),
+ maProperties.size());
+ }
+ }
+
+ ::std::vector<sal_Int32> GetSlidesPerPage (void) const
+ {
+ return maSlidesPerPage;
+ }
+
+ private:
+ Any maDialog;
+ ::std::vector<beans::PropertyValue> maProperties;
+ ::std::vector<sal_Int32> maSlidesPerPage;
+ bool mbImpress;
+
+ void ProcessResource (void)
+ {
+ SvtModuleOptions aOpt;
+ String aAppGroupname( String( SdResId( _STR_IMPRESS_PRINT_UI_GROUP_NAME ) ) );
+ aAppGroupname.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "%s" ) ),
+ aOpt.GetModuleName( mbImpress ? SvtModuleOptions::E_SIMPRESS : SvtModuleOptions::E_SDRAW ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getGroupControlOpt(
+ aAppGroupname,
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:TabPage:AppPage" ) )
+ ) );
+
+ uno::Sequence< rtl::OUString > aHelpIds;
+ if( mbImpress )
+ {
+ vcl::PrinterOptionsHelper::UIControlOptions aPrintOpt;
+ aPrintOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "JobPage" ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getSubgroupControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_PRINT_GROUP) ),
+ rtl::OUString(),
+ aPrintOpt )
+ );
+
+ aHelpIds.realloc( 1 );
+ aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageContentType:ListBox" ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getChoiceControlOpt(
+ String( SdResId( _STR_IMPRESS_PRINT_UI_CONTENT ) ),
+ aHelpIds,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "PageContentType" ) ),
+ CreateChoice(_STR_IMPRESS_PRINT_UI_CONTENT_CHOICES),
+ 0,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) )
+ )
+ );
+
+ aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:SlidesPerPage:ListBox" ) );
+ vcl::PrinterOptionsHelper::UIControlOptions
+ aContentOpt( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageContentType" ) ), 1 );
+ AddDialogControl( vcl::PrinterOptionsHelper::getChoiceControlOpt(
+ String( SdResId( _STR_IMPRESS_PRINT_UI_SLIDESPERPAGE ) ),
+ aHelpIds,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "SlidesPerPage" ) ),
+ GetSlidesPerPageSequence(),
+ 0,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ),
+ Sequence< sal_Bool >(),
+ aContentOpt
+ )
+ );
+
+ aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:SlidesPerPageOrder:ListBox" ) );
+ vcl::PrinterOptionsHelper::UIControlOptions
+ aSlidesPerPageOpt( OUString( RTL_CONSTASCII_USTRINGPARAM( "SlidesPerPage" ) ), -1, sal_True );
+ AddDialogControl( vcl::PrinterOptionsHelper::getChoiceControlOpt(
+ String( SdResId( _STR_IMPRESS_PRINT_UI_ORDER ) ),
+ aHelpIds,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "SlidesPerPageOrder" ) ),
+ CreateChoice(_STR_IMPRESS_PRINT_UI_ORDER_CHOICES),
+ 0,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ),
+ Sequence< sal_Bool >(),
+ aSlidesPerPageOpt )
+ );
+ }
+
+ AddDialogControl( vcl::PrinterOptionsHelper::getSubgroupControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_INCLUDE_CONTENT) ), rtl::OUString() ) );
+
+
+ if( mbImpress )
+ {
+ AddDialogControl( vcl::PrinterOptionsHelper::getBoolControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_IS_PRINT_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:IsPrintName:CheckBox" ) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "IsPrintName" ) ),
+ sal_False
+ )
+ );
+ }
+ else
+ {
+ AddDialogControl( vcl::PrinterOptionsHelper::getBoolControlOpt(
+ String( SdResId(_STR_DRAW_PRINT_UI_IS_PRINT_NAME) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:IsPrintName:CheckBox" ) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "IsPrintName" ) ),
+ sal_False
+ )
+ );
+ }
+
+ AddDialogControl( vcl::PrinterOptionsHelper::getBoolControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_IS_PRINT_DATE) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:IsPrintDateTime:CheckBox" ) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "IsPrintDateTime" ) ),
+ sal_False
+ )
+ );
+
+ if( mbImpress )
+ {
+ AddDialogControl( vcl::PrinterOptionsHelper::getBoolControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_IS_PRINT_HIDDEN) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:IsPrintHidden:CheckBox" ) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "IsPrintHidden" ) ),
+ sal_False
+ )
+ );
+ }
+
+ AddDialogControl( vcl::PrinterOptionsHelper::getSubgroupControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_QUALITY) ), rtl::OUString() ) );
+
+ aHelpIds.realloc( 3 );
+ aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:Quality:RadioButton:0" ) );
+ aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:Quality:RadioButton:1" ) );
+ aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:Quality:RadioButton:2" ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getChoiceControlOpt(
+ rtl::OUString(),
+ aHelpIds,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Quality" ) ),
+ CreateChoice(_STR_IMPRESS_PRINT_UI_QUALITY_CHOICES),
+ 0
+ )
+ );
+
+ AddDialogControl( vcl::PrinterOptionsHelper::getSubgroupControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_PAGE_OPTIONS) ), rtl::OUString() ) );
+
+ aHelpIds.realloc( 4 );
+ aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageOptions:RadioButton:0" ) );
+ aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageOptions:RadioButton:1" ) );
+ aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageOptions:RadioButton:2" ) );
+ aHelpIds[3] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageOptions:RadioButton:3" ) );
+ if( mbImpress )
+ {
+ // FIXME: additional dependency on PrintProspect = false
+ vcl::PrinterOptionsHelper::UIControlOptions
+ aPageOptionsOpt( OUString( RTL_CONSTASCII_USTRINGPARAM( "PageContentType" ) ), 0 );
+ AddDialogControl( vcl::PrinterOptionsHelper::getChoiceControlOpt(
+ rtl::OUString(),
+ aHelpIds,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "PageOptions" ) ),
+ CreateChoice(_STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES),
+ 0,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Radio" ) ),
+ Sequence< sal_Bool >(),
+ aPageOptionsOpt
+ )
+ );
+ }
+ else
+ {
+ vcl::PrinterOptionsHelper::UIControlOptions
+ aPageOptionsOpt( OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), sal_False );
+ AddDialogControl( vcl::PrinterOptionsHelper::getChoiceControlOpt(
+ rtl::OUString(),
+ aHelpIds,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "PageOptions" ) ),
+ CreateChoice(_STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES_DRAW),
+ 0,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Radio" ) ),
+ Sequence< sal_Bool >(),
+ aPageOptionsOpt
+ )
+ );
+ }
+
+ vcl::PrinterOptionsHelper::UIControlOptions aBrochureOpt;
+ aBrochureOpt.maGroupHint = OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getSubgroupControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_PAGE_SIDES) ), rtl::OUString(),
+ aBrochureOpt ) );
+
+ // brochure printing
+ AddDialogControl( vcl::PrinterOptionsHelper::getBoolControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_BROCHURE) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintProspect:CheckBox" ) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ),
+ sal_False,
+ aBrochureOpt
+ )
+ );
+
+ vcl::PrinterOptionsHelper::UIControlOptions
+ aIncludeOpt( OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspect" ) ), -1, sal_False );
+ aIncludeOpt.maGroupHint = OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutPage" ) );
+ aHelpIds.realloc( 1 );
+ aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintProspectInclude:ListBox" ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getChoiceControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE) ),
+ aHelpIds,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintProspectInclude" ) ),
+ CreateChoice(_STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE_LIST),
+ 0,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "List" ) ),
+ Sequence< sal_Bool >(),
+ aIncludeOpt
+ )
+ );
+
+ // paper tray (on options page)
+ vcl::PrinterOptionsHelper::UIControlOptions aPaperTrayOpt;
+ aPaperTrayOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OptionsPageOptGroup" ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getBoolControlOpt(
+ String( SdResId(_STR_IMPRESS_PRINT_UI_PAPER_TRAY) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintPaperFromSetup:CheckBox" ) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintPaperFromSetup" ) ),
+ sal_False,
+ aPaperTrayOpt
+ )
+ );
+ // print range selection
+ vcl::PrinterOptionsHelper::UIControlOptions aPrintRangeOpt;
+ aPrintRangeOpt.mbInternalOnly = sal_True;
+ aPrintRangeOpt.maGroupHint = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintRange" ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getSubgroupControlOpt(
+ String( SdResId( _STR_IMPRESS_PRINT_UI_PAGE_RANGE ) ),
+ rtl::OUString(),
+ aPrintRangeOpt )
+ );
+
+ // create a choice for the content to create
+ rtl::OUString aPrintRangeName( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) );
+ aHelpIds.realloc( 3 );
+ aHelpIds[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:0" ) );
+ aHelpIds[1] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:1" ) );
+ aHelpIds[2] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PrintContent:RadioButton:2" ) );
+ AddDialogControl( vcl::PrinterOptionsHelper::getChoiceControlOpt( rtl::OUString(),
+ aHelpIds,
+ aPrintRangeName,
+ CreateChoice(mbImpress
+ ? _STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE
+ : _STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE),
+ 0 )
+ );
+ // create a an Edit dependent on "Pages" selected
+ vcl::PrinterOptionsHelper::UIControlOptions aPageRangeOpt( aPrintRangeName, 1, sal_True );
+ AddDialogControl( vcl::PrinterOptionsHelper::getEditControlOpt( rtl::OUString(),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".HelpID:vcl:PrintDialog:PageRange:Edit" ) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) ),
+ rtl::OUString(),
+ aPageRangeOpt )
+ );
+
+ FreeResource();
+ }
+
+ void AddDialogControl( const Any& i_rCtrl )
+ {
+ beans::PropertyValue aVal;
+ aVal.Value = i_rCtrl;
+ maProperties.push_back( aVal );
+ }
+
+ Sequence<rtl::OUString> CreateChoice (const sal_uInt16 nResourceId) const
+ {
+ SdResId aResourceId (nResourceId);
+ ResStringArray aChoiceStrings (aResourceId);
+
+ const sal_uInt32 nCount (aChoiceStrings.Count());
+ Sequence<rtl::OUString> aChoices (nCount);
+ for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
+ aChoices[nIndex] = aChoiceStrings.GetString(nIndex);
+
+ return aChoices;
+ }
+
+ Sequence<rtl::OUString> GetSlidesPerPageSequence (void)
+ {
+ const Sequence<rtl::OUString> aChoice (
+ CreateChoice(_STR_IMPRESS_PRINT_UI_SLIDESPERPAGE_CHOICES));
+ maSlidesPerPage.clear();
+ maSlidesPerPage.push_back(0); // first is using the default
+ for (sal_Int32 nIndex=1,nCount=aChoice.getLength(); nIndex<nCount; ++nIndex)
+ maSlidesPerPage.push_back(aChoice[nIndex].toInt32());
+ return aChoice;
+ }
+ };
+
+
+
+
+ /** The Prepare... methods of the DocumentRenderer::Implementation class
+ create a set of PrinterPage objects that contain all necessary
+ information to do the actual printing. There is one PrinterPage
+ object per printed page. Derived classes implement the actual, mode
+ specific printing.
+
+ This and all derived classes support the asynchronous printing
+ process by not storing pointers to any data with lifetime shorter
+ than the PrinterPage objects, i.e. slides, shapes, (one of) the
+ outliner (of the document).
+ */
+ class PrinterPage
+ {
+ public:
+ PrinterPage (
+ const PageKind ePageKind,
+ const MapMode& rMapMode,
+ const bool bPrintMarkedOnly,
+ const ::rtl::OUString& rsPageString,
+ const Point& rPageStringOffset,
+ const sal_uLong nDrawMode,
+ const Orientation eOrientation,
+ const sal_uInt16 nPaperTray)
+ : mePageKind(ePageKind),
+ maMap(rMapMode),
+ mbPrintMarkedOnly(bPrintMarkedOnly),
+ msPageString(rsPageString),
+ maPageStringOffset(rPageStringOffset),
+ mnDrawMode(nDrawMode),
+ meOrientation(eOrientation),
+ mnPaperTray(nPaperTray)
+ {
+ }
+
+ virtual ~PrinterPage (void) {}
+
+ virtual void Print (
+ Printer& rPrinter,
+ SdDrawDocument& rDocument,
+ ViewShell& rViewShell,
+ View* pView,
+ DrawView& rPrintView,
+ const SetOfByte& rVisibleLayers,
+ const SetOfByte& rPrintableLayers) const = 0;
+
+ sal_uLong GetDrawMode (void) const { return mnDrawMode; }
+ Orientation GetOrientation (void) const { return meOrientation; }
+ sal_uInt16 GetPaperTray (void) const { return mnPaperTray; }
+
+ protected:
+ const PageKind mePageKind;
+ const MapMode maMap;
+ const bool mbPrintMarkedOnly;
+ const ::rtl::OUString msPageString;
+ const Point maPageStringOffset;
+ const sal_uLong mnDrawMode;
+ const Orientation meOrientation;
+ const sal_uInt16 mnPaperTray;
+ };
+
+
+
+
+ /** The RegularPrinterPage is used for printing one regular slide (no
+ notes, handout, or outline) to one printer page.
+ */
+ class RegularPrinterPage : public PrinterPage
+ {
+ public:
+ RegularPrinterPage (
+ const sal_uInt16 nPageIndex,
+ const PageKind ePageKind,
+ const MapMode& rMapMode,
+ const bool bPrintMarkedOnly,
+ const ::rtl::OUString& rsPageString,
+ const Point& rPageStringOffset,
+ const sal_uLong nDrawMode,
+ const Orientation eOrientation,
+ const sal_uInt16 nPaperTray)
+ : PrinterPage(ePageKind, rMapMode, bPrintMarkedOnly, rsPageString,
+ rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
+ mnPageIndex(nPageIndex)
+ {
+ }
+
+ virtual ~RegularPrinterPage (void) {}
+
+ virtual void Print (
+ Printer& rPrinter,
+ SdDrawDocument& rDocument,
+ ViewShell& rViewShell,
+ View* pView,
+ DrawView& rPrintView,
+ const SetOfByte& rVisibleLayers,
+ const SetOfByte& rPrintableLayers) const
+ {
+ (void)rViewShell;
+ SdPage* pPageToPrint = rDocument.GetSdPage(mnPageIndex, mePageKind);
+ rPrinter.SetMapMode(maMap);
+ PrintPage(
+ rPrinter,
+ rPrintView,
+ *pPageToPrint,
+ pView,
+ mbPrintMarkedOnly,
+ rVisibleLayers,
+ rPrintableLayers);
+ PrintMessage(
+ rPrinter,
+ msPageString,
+ maPageStringOffset);
+ }
+
+ private:
+ const sal_uInt16 mnPageIndex;
+ };
+
+
+
+
+ /** Print one slide multiple times on a printer page so that the whole
+ printer page is covered.
+ */
+ class TiledPrinterPage : public PrinterPage
+ {
+ public:
+ TiledPrinterPage (
+ const sal_uInt16 nPageIndex,
+ const PageKind ePageKind,
+ const sal_Int32 nGap,
+ const bool bPrintMarkedOnly,
+ const ::rtl::OUString& rsPageString,
+ const Point& rPageStringOffset,
+ const sal_uLong nDrawMode,
+ const Orientation eOrientation,
+ const sal_uInt16 nPaperTray)
+ : PrinterPage(ePageKind, MapMode(), bPrintMarkedOnly, rsPageString,
+ rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
+ mnPageIndex(nPageIndex),
+ mnGap(nGap)
+ {
+ }
+
+ virtual ~TiledPrinterPage (void) {}
+
+ virtual void Print (
+ Printer& rPrinter,
+ SdDrawDocument& rDocument,
+ ViewShell& rViewShell,
+ View* pView,
+ DrawView& rPrintView,
+ const SetOfByte& rVisibleLayers,
+ const SetOfByte& rPrintableLayers) const
+ {
+ (void)rViewShell;
+ SdPage* pPageToPrint = rDocument.GetSdPage(mnPageIndex, mePageKind);
+ if (pPageToPrint==NULL)
+ return;
+ MapMode aMap (rPrinter.GetMapMode());
+
+ const Size aPageSize (pPageToPrint->GetSize());
+ const Size aPrintSize (rPrinter.GetOutputSize());
+
+ const sal_Int32 nPageWidth (aPageSize.Width() + mnGap
+ - pPageToPrint->GetLftBorder() - pPageToPrint->GetRgtBorder());
+ const sal_Int32 nPageHeight (aPageSize.Height() + mnGap
+ - pPageToPrint->GetUppBorder() - pPageToPrint->GetLwrBorder());
+ if (nPageWidth<=0 || nPageHeight<=0)
+ return;
+
+ // Print at least two rows and columns. More if the document
+ // page fits completely onto the printer page.
+ const sal_Int32 nColumnCount (::std::max(sal_Int32(2),
+ sal_Int32(aPrintSize.Width() / nPageWidth)));
+ const sal_Int32 nRowCount (::std::max(sal_Int32(2),
+ sal_Int32(aPrintSize.Height() / nPageHeight)));
+ Point aPrintOrigin;
+ for (sal_Int32 nRow=0; nRow<nRowCount; ++nRow)
+ for (sal_Int32 nColumn=0; nColumn<nColumnCount; ++nColumn)
+ {
+ aMap.SetOrigin(Point(nColumn*nPageWidth,nRow*nPageHeight));
+ rPrinter.SetMapMode(aMap);
+ PrintPage(
+ rPrinter,
+ rPrintView,
+ *pPageToPrint,
+ pView,
+ mbPrintMarkedOnly,
+ rVisibleLayers,
+ rPrintableLayers);
+ }
+
+ PrintMessage(
+ rPrinter,
+ msPageString,
+ maPageStringOffset);
+ }
+
+ private:
+ const sal_uInt16 mnPageIndex;
+ const sal_Int32 mnGap;
+ };
+
+ /** Print two slides to one printer page so that the resulting pages
+ form a booklet.
+ */
+ class BookletPrinterPage : public PrinterPage
+ {
+ public:
+ BookletPrinterPage (
+ const sal_uInt16 nFirstPageIndex,
+ const sal_uInt16 nSecondPageIndex,
+ const Point& rFirstOffset,
+ const Point& rSecondOffset,
+ const PageKind ePageKind,
+ const MapMode& rMapMode,
+ const bool bPrintMarkedOnly,
+ const sal_uLong nDrawMode,
+ const Orientation eOrientation,
+ const sal_uInt16 nPaperTray)
+ : PrinterPage(ePageKind, rMapMode, bPrintMarkedOnly, ::rtl::OUString(),
+ Point(), nDrawMode, eOrientation, nPaperTray),
+ mnFirstPageIndex(nFirstPageIndex),
+ mnSecondPageIndex(nSecondPageIndex),
+ maFirstOffset(rFirstOffset),
+ maSecondOffset(rSecondOffset)
+ {
+ }
+
+ virtual ~BookletPrinterPage (void) {}
+
+ virtual void Print (
+ Printer& rPrinter,
+ SdDrawDocument& rDocument,
+ ViewShell& rViewShell,
+ View* pView,
+ DrawView& rPrintView,
+ const SetOfByte& rVisibleLayers,
+ const SetOfByte& rPrintableLayers) const
+ {
+ (void)rViewShell;
+ MapMode aMap (maMap);
+ SdPage* pPageToPrint = rDocument.GetSdPage(mnFirstPageIndex, mePageKind);
+ if (pPageToPrint)
+ {
+ aMap.SetOrigin(maFirstOffset);
+ rPrinter.SetMapMode(aMap);
+ PrintPage(
+ rPrinter,
+ rPrintView,
+ *pPageToPrint,
+ pView,
+ mbPrintMarkedOnly,
+ rVisibleLayers,
+ rPrintableLayers);
+ }
+
+ pPageToPrint = rDocument.GetSdPage(mnSecondPageIndex, mePageKind);
+ if( pPageToPrint )
+ {
+ aMap.SetOrigin(maSecondOffset);
+ rPrinter.SetMapMode(aMap);
+ PrintPage(
+ rPrinter,
+ rPrintView,
+ *pPageToPrint,
+ pView,
+ mbPrintMarkedOnly,
+ rVisibleLayers,
+ rPrintableLayers);
+ }
+ }
+
+ private:
+ const sal_uInt16 mnFirstPageIndex;
+ const sal_uInt16 mnSecondPageIndex;
+ const Point maFirstOffset;
+ const Point maSecondOffset;
+ };
+
+
+
+
+ /** One handout page displays one to nine slides.
+ */
+ class HandoutPrinterPage : public PrinterPage
+ {
+ public:
+ HandoutPrinterPage (
+ const sal_uInt16 nHandoutPageIndex,
+ const ::std::vector<sal_uInt16>& rPageIndices,
+ const MapMode& rMapMode,
+ const ::rtl::OUString& rsPageString,
+ const Point& rPageStringOffset,
+ const sal_uLong nDrawMode,
+ const Orientation eOrientation,
+ const sal_uInt16 nPaperTray)
+ : PrinterPage(PK_HANDOUT, rMapMode, false, rsPageString,
+ rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
+ mnHandoutPageIndex(nHandoutPageIndex),
+ maPageIndices(rPageIndices)
+ {
+ }
+
+ virtual void Print (
+ Printer& rPrinter,
+ SdDrawDocument& rDocument,
+ ViewShell& rViewShell,
+ View* pView,
+ DrawView& rPrintView,
+ const SetOfByte& rVisibleLayers,
+ const SetOfByte& rPrintableLayers) const
+ {
+ SdPage& rHandoutPage (*rDocument.GetSdPage(0, PK_HANDOUT));
+
+ Reference< com::sun::star::beans::XPropertySet > xHandoutPage( rHandoutPage.getUnoPage(), UNO_QUERY );
+ const rtl::OUString sPageNumber( RTL_CONSTASCII_USTRINGPARAM( "Number" ) );
+
+ // Collect the page objects of the handout master.
+ std::vector<SdrPageObj*> aHandoutPageObjects;
+ SdrObjListIter aShapeIter (rHandoutPage);
+ while (aShapeIter.IsMore())
+ {
+ SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
+ if (pPageObj)
+ aHandoutPageObjects.push_back(pPageObj);
+ }
+ if (aHandoutPageObjects.empty())
+ return;
+
+ // Connect page objects with pages.
+ std::vector<SdrPageObj*>::iterator aPageObjIter (aHandoutPageObjects.begin());
+ for (std::vector<sal_uInt16>::const_iterator
+ iPageIndex(maPageIndices.begin()),
+ iEnd(maPageIndices.end());
+ iPageIndex!=iEnd && aPageObjIter!=aHandoutPageObjects.end();
+ ++iPageIndex)
+ {
+ // Check if the page still exists.
+ if (*iPageIndex >= rDocument.GetSdPageCount(PK_STANDARD))
+ continue;
+
+ SdrPageObj* pPageObj = (*aPageObjIter++);
+ pPageObj->SetReferencedPage(rDocument.GetSdPage(*iPageIndex, PK_STANDARD));
+ }
+
+ // if there are more page objects than pages left, set the rest to invisible
+ int nHangoverCount = 0;
+ while (aPageObjIter != aHandoutPageObjects.end())
+ {
+ (*aPageObjIter++)->SetReferencedPage(0L);
+ nHangoverCount++;
+ }
+
+ // Hide outlines for objects that have pages attached.
+ if (nHangoverCount > 0)
+ {
+ int nSkip = aHandoutPageObjects.size() - nHangoverCount;
+ aShapeIter.Reset();
+ while (aShapeIter.IsMore())
+ {
+ SdrPathObj* pPathObj = dynamic_cast<SdrPathObj*>(aShapeIter.Next());
+ if (pPathObj)
+ {
+ if (nSkip > 0)
+ --nSkip;
+ else
+ pPathObj->SetMergedItem(XLineStyleItem(XLINE_NONE));
+ }
+ }
+ }
+
+ if( xHandoutPage.is() ) try
+ {
+ xHandoutPage->setPropertyValue( sPageNumber, Any( static_cast<sal_Int16>(mnHandoutPageIndex) ) );
+ }
+ catch( Exception& )
+ {
+ }
+ rViewShell.SetPrintedHandoutPageNum( mnHandoutPageIndex + 1 );
+
+ MapMode aMap (rPrinter.GetMapMode());
+ rPrinter.SetMapMode(maMap);
+
+ PrintPage(
+ rPrinter,
+ rPrintView,
+ rHandoutPage,
+ pView,
+ false,
+ rVisibleLayers,
+ rPrintableLayers);
+ PrintMessage(
+ rPrinter,
+ msPageString,
+ maPageStringOffset);
+
+ if( xHandoutPage.is() ) try
+ {
+ xHandoutPage->setPropertyValue( sPageNumber, Any( static_cast<sal_Int16>(0) ) );
+ }
+ catch( Exception& )
+ {
+ }
+ rViewShell.SetPrintedHandoutPageNum(1);
+
+ // Restore outlines.
+ if (nHangoverCount > 0)
+ {
+ aShapeIter.Reset();
+ while (aShapeIter.IsMore())
+ {
+ SdrPathObj* pPathObj = dynamic_cast<SdrPathObj*>(aShapeIter.Next());
+ if (pPathObj != NULL)
+ pPathObj->SetMergedItem(XLineStyleItem(XLINE_SOLID));
+ }
+ }
+
+ }
+
+ private:
+ const sal_uInt16 mnHandoutPageIndex;
+ const ::std::vector<sal_uInt16> maPageIndices;
+ };
+
+
+
+
+ /** The outline information (title, subtitle, outline objects) of the
+ document. There is no fixed mapping of slides to printer pages.
+ */
+ class OutlinerPrinterPage : public PrinterPage
+ {
+ public:
+ OutlinerPrinterPage (
+ OutlinerParaObject* pParaObject,
+ const MapMode& rMapMode,
+ const ::rtl::OUString& rsPageString,
+ const Point& rPageStringOffset,
+ const sal_uLong nDrawMode,
+ const Orientation eOrientation,
+ const sal_uInt16 nPaperTray)
+ : PrinterPage(PK_HANDOUT, rMapMode, false, rsPageString,
+ rPageStringOffset, nDrawMode, eOrientation, nPaperTray),
+ mpParaObject(pParaObject)
+ {
+ }
+
+ ~OutlinerPrinterPage (void)
+ {
+ mpParaObject.reset();
+ }
+
+ virtual void Print (
+ Printer& rPrinter,
+ SdDrawDocument& rDocument,
+ ViewShell& rViewShell,
+ View* pView,
+ DrawView& rPrintView,
+ const SetOfByte& rVisibleLayers,
+ const SetOfByte& rPrintableLayers) const
+ {
+ (void)rViewShell;
+ (void)pView;
+ (void)rPrintView;
+ (void)rVisibleLayers;
+ (void)rPrintableLayers;
+
+ // Set up the printer.
+ rPrinter.SetMapMode(maMap);
+
+ // Get and set up the outliner.
+ const Rectangle aOutRect (rPrinter.GetPageOffset(), rPrinter.GetOutputSize());
+ Outliner* pOutliner = rDocument.GetInternalOutliner();
+ const sal_uInt16 nSavedOutlMode (pOutliner->GetMode());
+ const sal_Bool bSavedUpdateMode (pOutliner->GetUpdateMode());
+ const Size aSavedPaperSize (pOutliner->GetPaperSize());
+
+ pOutliner->Init(OUTLINERMODE_OUTLINEVIEW);
+ pOutliner->SetPaperSize(aOutRect.GetSize());
+ pOutliner->SetUpdateMode(sal_True);
+ pOutliner->Clear();
+ pOutliner->SetText(*mpParaObject);
+
+ pOutliner->Draw(&rPrinter, aOutRect);
+
+ PrintMessage(
+ rPrinter,
+ msPageString,
+ maPageStringOffset);
+
+ // Restore outliner and printer.
+ pOutliner->Clear();
+ pOutliner->SetUpdateMode(bSavedUpdateMode);
+ pOutliner->SetPaperSize(aSavedPaperSize);
+ pOutliner->Init(nSavedOutlMode);
+ }
+
+ private:
+ ::boost::scoped_ptr<OutlinerParaObject> mpParaObject;
+ };
+}
+
+
+//===== DocumentRenderer::Implementation ======================================
+
+class DocumentRenderer::Implementation
+ : public SfxListener,
+ public vcl::PrinterOptionsHelper
+{
+public:
+ Implementation (ViewShellBase& rBase)
+ : mrBase(rBase),
+ mbIsDisposed(false),
+ mpPrinter(NULL),
+ mpOptions(),
+ maPrinterPages(),
+ mpPrintView(),
+ mbHasOrientationWarningBeenShown(false)
+ {
+ DialogCreator aCreator( mrBase.GetDocShell()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS );
+ m_aUIProperties = aCreator.GetDialogControls();
+ maSlidesPerPage = aCreator.GetSlidesPerPage();
+
+ StartListening(mrBase);
+ }
+
+
+
+
+ virtual ~Implementation (void)
+ {
+ EndListening(mrBase);
+ }
+
+
+
+
+ virtual void Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint)
+ {
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if (pSimpleHint != NULL
+ && pSimpleHint->GetId() == SFX_HINT_DYING
+ && &rBroadcaster == &static_cast<SfxBroadcaster&>(mrBase))
+ {
+ Dispose();
+ }
+ }
+
+
+
+ /** Process the sequence of properties given to one of the XRenderable
+ methods.
+ */
+ void ProcessProperties (const css::uno::Sequence<css::beans::PropertyValue >& rOptions)
+ {
+ OSL_ASSERT(!mbIsDisposed);
+ if (mbIsDisposed)
+ return;
+
+ bool bIsValueChanged = processProperties( rOptions );
+ bool bIsPaperChanged = false;
+
+ // The RenderDevice property is handled specially: its value is
+ // stored in mpPrinter instead of being retrieved on demand.
+ Any aDev( getValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "RenderDevice" ) ) ) );
+ Reference<awt::XDevice> xRenderDevice;
+
+ if (aDev >>= xRenderDevice)
+ {
+ VCLXDevice* pDevice = VCLXDevice::GetImplementation(xRenderDevice);
+ OutputDevice* pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
+ mpPrinter = dynamic_cast<Printer*>(pOut);
+ Size aPageSizePixel = mpPrinter ? mpPrinter->GetPaperSizePixel() : Size();
+ if( aPageSizePixel != maPrinterPageSizePixel )
+ {
+ bIsPaperChanged = true;
+ maPrinterPageSizePixel = aPageSizePixel;
+ }
+ }
+
+ if (bIsValueChanged)
+ {
+ if ( ! mpOptions )
+ mpOptions.reset(new PrintOptions(*this, maSlidesPerPage));
+ }
+ if( bIsValueChanged || bIsPaperChanged )
+ PreparePages();
+ }
+
+
+
+ /** Return the number of pages that are to be printed.
+ */
+ sal_Int32 GetPrintPageCount (void)
+ {
+ OSL_ASSERT(!mbIsDisposed);
+ if (mbIsDisposed)
+ return 0;
+ else
+ return maPrinterPages.size();
+ }
+
+
+
+ /** Return a sequence of properties that can be returned by the
+ XRenderable::getRenderer() method.
+ */
+ css::uno::Sequence<css::beans::PropertyValue> GetProperties (
+ const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
+ {
+ (void)rOptions;
+
+ css::uno::Sequence<css::beans::PropertyValue> aProperties (3);
+
+ aProperties[0].Name = A2S("ExtraPrintUIOptions");
+ aProperties[0].Value <<= m_aUIProperties;
+
+ aProperties[1].Name = A2S("PageSize");
+ aProperties[1].Value <<= maPrintSize;
+
+ // FIXME: is this always true ?
+ aProperties[2].Name = A2S("PageIncludesNonprintableArea");
+ aProperties[2].Value = makeAny( sal_True );
+
+ return aProperties;
+ }
+
+
+
+
+ /** Print one of the prepared pages.
+ */
+ void PrintPage (const sal_Int32 nIndex)
+ {
+ OSL_ASSERT(!mbIsDisposed);
+ if (mbIsDisposed)
+ return;
+
+ Printer& rPrinter (*mpPrinter);
+
+ ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
+ if ( ! pViewShell)
+ return;
+
+ SdDrawDocument* pDocument = pViewShell->GetDoc();
+ OSL_ASSERT(pDocument!=NULL);
+
+ ::boost::shared_ptr<DrawViewShell> pDrawViewShell(
+ ::boost::dynamic_pointer_cast<DrawViewShell>(mrBase.GetMainViewShell()));
+
+ if ( ! mpPrintView)
+ mpPrintView.reset(new DrawView(mrBase.GetDocShell(), &rPrinter, pDrawViewShell.get()));
+
+ if (nIndex<0 || sal::static_int_cast<sal_uInt32>(nIndex)>=maPrinterPages.size())
+ return;
+
+ const ::boost::shared_ptr<PrinterPage> pPage (maPrinterPages[nIndex]);
+ OSL_ASSERT(pPage);
+ if ( ! pPage)
+ return;
+
+ const Orientation eSavedOrientation (rPrinter.GetOrientation());
+ const sal_uLong nSavedDrawMode (rPrinter.GetDrawMode());
+ const MapMode aSavedMapMode (rPrinter.GetMapMode());
+ const sal_uInt16 nSavedPaperBin (rPrinter.GetPaperBin());
+
+
+ // Set page orientation.
+ if ( ! rPrinter.SetOrientation(pPage->GetOrientation()))
+ {
+ if ( ! mbHasOrientationWarningBeenShown
+ && mpOptions->IsWarningOrientation())
+ {
+ mbHasOrientationWarningBeenShown = true;
+ // Show warning that the orientation could not be set.
+ if (pViewShell)
+ {
+ WarningBox aWarnBox(
+ pViewShell->GetActiveWindow(),
+ (WinBits)(WB_OK_CANCEL | WB_DEF_CANCEL),
+ String(SdResId(STR_WARN_PRINTFORMAT_FAILURE)));
+ if (aWarnBox.Execute() != RET_OK)
+ return;
+ }
+ }
+ }
+
+ // Set the draw mode.
+ rPrinter.SetDrawMode(pPage->GetDrawMode());
+
+ // Set paper tray.
+ rPrinter.SetPaperBin(pPage->GetPaperTray());
+
+ // Print the actual page.
+ pPage->Print(
+ rPrinter,
+ *pDocument,
+ *pViewShell,
+ pDrawViewShell ? pDrawViewShell->GetView() : NULL,
+ *mpPrintView,
+ pViewShell->GetFrameView()->GetVisibleLayers(),
+ pViewShell->GetFrameView()->GetPrintableLayers());
+
+ rPrinter.SetOrientation(eSavedOrientation);
+ rPrinter.SetDrawMode(nSavedDrawMode);
+ rPrinter.SetMapMode(aSavedMapMode);
+ rPrinter.SetPaperBin(nSavedPaperBin);
+ }
+
+
+
+
+private:
+ ViewShellBase& mrBase;
+ bool mbIsDisposed;
+ Printer* mpPrinter;
+ Size maPrinterPageSizePixel;
+ ::boost::scoped_ptr<PrintOptions> mpOptions;
+ ::std::vector< ::boost::shared_ptr< ::sd::PrinterPage> > maPrinterPages;
+ ::boost::scoped_ptr<DrawView> mpPrintView;
+ bool mbHasOrientationWarningBeenShown;
+ ::std::vector<sal_Int32> maSlidesPerPage;
+ awt::Size maPrintSize;
+
+ void Dispose (void)
+ {
+ mbIsDisposed = true;
+ }
+
+
+
+ /** Determine and set the paper orientation.
+ */
+ bool SetupPaperOrientation (
+ const PageKind ePageKind,
+ PrintInfo& rInfo)
+ {
+ SdDrawDocument* pDocument = mrBase.GetMainViewShell()->GetDoc();
+ rInfo.meOrientation = ORIENTATION_PORTRAIT;
+
+ if( ! mpOptions->IsBooklet())
+ {
+ rInfo.meOrientation = pDocument->GetSdPage(0, ePageKind)->GetOrientation();
+ }
+ else if (rInfo.maPageSize.Width() < rInfo.maPageSize.Height())
+ rInfo.meOrientation = ORIENTATION_LANDSCAPE;
+
+ const Size aPaperSize (rInfo.mpPrinter->GetPaperSize());
+ if( (rInfo.meOrientation == ORIENTATION_LANDSCAPE &&
+ (aPaperSize.Width() < aPaperSize.Height()))
+ ||
+ (rInfo.meOrientation == ORIENTATION_PORTRAIT &&
+ (aPaperSize.Width() > aPaperSize.Height()))
+ )
+ {
+ maPrintSize = awt::Size(aPaperSize.Height(), aPaperSize.Width());
+ // rInfo.maPrintSize = Size(rInfo.maPrintSize.Height(), rInfo.maPrintSize.Width());
+ }
+ else
+ {
+ maPrintSize = awt::Size(aPaperSize.Width(), aPaperSize.Height());
+ }
+
+ return true;
+ }
+
+
+
+ /** Top most method for preparing printer pages. In this and the other
+ Prepare... methods the various special cases are detected and
+ handled.
+ For every page that is to be printed (that may contain several
+ slides) one PrinterPage object is created and inserted into
+ maPrinterPages.
+ */
+ void PreparePages (void)
+ {
+ mpPrintView.reset();
+ maPrinterPages.clear();
+ mbHasOrientationWarningBeenShown = false;
+
+ ViewShell* pShell = mrBase.GetMainViewShell().get();
+
+ PrintInfo aInfo (mpPrinter, mpOptions->GetPrinterSelection(), mrBase.GetMainViewShell());
+
+ if (aInfo.mpPrinter!=NULL && pShell!=NULL)
+ {
+
+ MapMode aMap (aInfo.mpPrinter->GetMapMode());
+ aMap.SetMapUnit(MAP_100TH_MM);
+ aInfo.maMap = aMap;
+ mpPrinter->SetMapMode(aMap);
+
+ ::Outliner& rOutliner = mrBase.GetDocument()->GetDrawOutliner();
+ const sal_uLong nSavedControlWord (rOutliner.GetControlWord());
+ sal_uLong nCntrl = nSavedControlWord;
+ nCntrl &= ~EE_CNTRL_MARKFIELDS;
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+ rOutliner.SetControlWord( nCntrl );
+
+ // When in outline view then apply all pending changes to the model.
+ if (pShell->ISA(OutlineViewShell))
+ static_cast<OutlineViewShell*>(pShell)->PrepareClose (sal_False, sal_False);
+
+ // Collect some frequently used data.
+ if (mpOptions->IsDate())
+ {
+ aInfo.msTimeDate += GetSdrGlobalData().GetLocaleData()->getDate( Date() );
+ aInfo.msTimeDate += ::rtl::OUString((sal_Unicode)' ');
+ }
+
+ if (mpOptions->IsTime())
+ aInfo.msTimeDate += GetSdrGlobalData().GetLocaleData()->getTime( Time(), sal_False, sal_False );
+ aInfo.maPrintSize = aInfo.mpPrinter->GetOutputSize();
+ maPrintSize = awt::Size(
+ aInfo.mpPrinter->GetPaperSize().Width(),
+ aInfo.mpPrinter->GetPaperSize().Height());
+
+ switch (mpOptions->GetOutputQuality())
+ {
+ case 1:
+ aInfo.mnDrawMode = DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL
+ | DRAWMODE_BLACKTEXT | DRAWMODE_GRAYBITMAP
+ | DRAWMODE_GRAYGRADIENT;
+ break;
+
+ case 2:
+ aInfo.mnDrawMode = DRAWMODE_BLACKLINE | DRAWMODE_BLACKTEXT
+ | DRAWMODE_WHITEFILL | DRAWMODE_GRAYBITMAP
+ | DRAWMODE_WHITEGRADIENT;
+ break;
+
+ default:
+ aInfo.mnDrawMode = DRAWMODE_DEFAULT;
+ }
+
+ // check if selected range of pages contains transparent objects
+ /*
+ const bool bPrintPages (bPrintNotes || bPrintDraw || bPrintHandout);
+ const bool bContainsTransparency (bPrintPages && ContainsTransparency());
+ if (pPrinter->InitJob (mrBase.GetWindow(), !bIsAPI && bContainsTransparency))
+ */
+
+ if (mpOptions->IsDraw())
+ PrepareStdOrNotes(PK_STANDARD, aInfo);
+ if (mpOptions->IsNotes())
+ PrepareStdOrNotes(PK_NOTES, aInfo);
+ if (mpOptions->IsHandout())
+ {
+ InitHandoutTemplate();
+ PrepareHandout(aInfo);
+ }
+ if (mpOptions->IsOutline())
+ PrepareOutline(aInfo);
+
+ rOutliner.SetControlWord(nSavedControlWord);
+ }
+ }
+
+
+
+
+ /** Create the page objects of the handout template. When the actual
+ printing takes place then the page objects are assigned different
+ sets of slides for each printed page (see HandoutPrinterPage::Print).
+ */
+ void InitHandoutTemplate (void)
+ {
+ const sal_Int32 nSlidesPerHandout (mpOptions->GetHandoutPageCount());
+ const bool bHandoutHorizontal (mpOptions->IsHandoutHorizontal());
+
+ AutoLayout eLayout = AUTOLAYOUT_HANDOUT6;
+ switch (nSlidesPerHandout)
+ {
+ case 0: eLayout = AUTOLAYOUT_NONE; break; // AUTOLAYOUT_HANDOUT1; break;
+ case 1: eLayout = AUTOLAYOUT_HANDOUT1; break;
+ case 2: eLayout = AUTOLAYOUT_HANDOUT2; break;
+ case 3: eLayout = AUTOLAYOUT_HANDOUT3; break;
+ case 4: eLayout = AUTOLAYOUT_HANDOUT4; break;
+ default:
+ case 6: eLayout = AUTOLAYOUT_HANDOUT6; break;
+ case 9: eLayout = AUTOLAYOUT_HANDOUT9; break;
+ }
+
+ if( !mrBase.GetDocument() )
+ return;
+
+ SdDrawDocument& rModel = *mrBase.GetDocument();
+
+ // first, prepare handout page (not handout master)
+
+ SdPage* pHandout = rModel.GetSdPage(0, PK_HANDOUT);
+ if( !pHandout )
+ return;
+
+ // delete all previous shapes from handout page
+ while( pHandout->GetObjCount() )
+ {
+ SdrObject* pObj = pHandout->NbcRemoveObject(0);
+ if( pObj )
+ SdrObject::Free( pObj );
+ }
+
+ const bool bDrawLines (eLayout == AUTOLAYOUT_HANDOUT3);
+
+ std::vector< Rectangle > aAreas;
+ SdPage::CalculateHandoutAreas( rModel, eLayout, bHandoutHorizontal, aAreas );
+
+ std::vector< Rectangle >::iterator iter( aAreas.begin() );
+ while( iter != aAreas.end() )
+ {
+ pHandout->NbcInsertObject( new SdrPageObj((*iter++)) );
+
+ if( bDrawLines && (iter != aAreas.end()) )
+ {
+ Rectangle aRect( (*iter++) );
+
+ basegfx::B2DPolygon aPoly;
+ aPoly.insert(0, basegfx::B2DPoint( aRect.Left(), aRect.Top() ) );
+ aPoly.insert(1, basegfx::B2DPoint( aRect.Right(), aRect.Top() ) );
+
+ basegfx::B2DHomMatrix aMatrix;
+ aMatrix.translate( 0.0, static_cast< double >( aRect.GetHeight() / 7 ) );
+
+ basegfx::B2DPolyPolygon aPathPoly;
+ for( sal_uInt16 nLine = 0; nLine < 7; nLine++ )
+ {
+ aPoly.transform( aMatrix );
+ aPathPoly.append( aPoly );
+ }
+
+ SdrPathObj* pPathObj = new SdrPathObj(OBJ_PATHLINE, aPathPoly );
+ pPathObj->SetMergedItem(XLineStyleItem(XLINE_SOLID));
+ pPathObj->SetMergedItem(XLineColorItem(String(), Color(COL_BLACK)));
+
+ pHandout->NbcInsertObject( pPathObj );
+ }
+ }
+ }
+
+
+
+
+ /** Detect whether any of the slides that are to be printed contains
+ partially transparent or translucent shapes.
+ */
+ bool ContainsTransparency (const PrintInfo& rInfo) const
+ {
+ // const bool bPrintExcluded (mpOptions->IsPrintExcluded());
+ bool bContainsTransparency = false;
+
+ for (sal_uInt16
+ nIndex=0,
+ nCount=mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
+ nIndex < nCount && !bContainsTransparency;
+ ++nIndex)
+ {
+ SdPage* pPage = GetFilteredPage(nIndex, PK_STANDARD, rInfo);
+ if (pPage == NULL)
+ continue;
+
+ bContainsTransparency = pPage->HasTransparentObjects();
+ if ( ! bContainsTransparency && pPage->TRG_HasMasterPage())
+ bContainsTransparency = pPage->TRG_GetMasterPage().HasTransparentObjects();
+ }
+
+ return bContainsTransparency;
+ }
+
+
+
+
+ /** Detect whether the specified slide is to be printed.
+ @return
+ When the slide is not to be printed then <NULL/> is returned.
+ Otherwise a pointer to the slide is returned.
+ */
+ SdPage* GetFilteredPage (
+ const sal_Int32 nPageIndex,
+ const PageKind ePageKind,
+ const PrintInfo& rInfo) const
+ {
+ OSL_ASSERT(mrBase.GetDocument() != NULL);
+ OSL_ASSERT(nPageIndex>=0);
+ if ( ! rInfo.maSelection.IsSelected(nPageIndex))
+ return NULL;
+ SdPage* pPage = mrBase.GetDocument()->GetSdPage(
+ sal::static_int_cast<sal_uInt16>(nPageIndex),
+ ePageKind);
+ if (pPage == NULL)
+ return NULL;
+ if ( ! pPage->IsExcluded() || mpOptions->IsPrintExcluded())
+ return pPage;
+ else
+ return NULL;
+ }
+
+
+
+
+ /** Prepare the outline of the document for printing. There is no fixed
+ number of slides whose outline data is put onto one printer page.
+ If the current printer page has enough room for the outline of the
+ current slide then that is added. Otherwise a new printer page is
+ started.
+ */
+ void PrepareOutline (PrintInfo& rInfo)
+ {
+ MapMode aMap (rInfo.maMap);
+ Point aPageOfs (rInfo.mpPrinter->GetPageOffset() );
+ // aMap.SetOrigin(Point() - aPageOfs);
+ aMap.SetScaleX(Fraction(1,2));
+ aMap.SetScaleY(Fraction(1,2));
+ mpPrinter->SetMapMode(aMap);
+
+ Rectangle aOutRect(aPageOfs, rInfo.mpPrinter->GetOutputSize());
+ if( aOutRect.GetWidth() > aOutRect.GetHeight() )
+ {
+ Size aPaperSize( rInfo.mpPrinter->PixelToLogic( rInfo.mpPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ) );
+ maPrintSize.Width = aPaperSize.Height();
+ maPrintSize.Height = aPaperSize.Width();
+ aOutRect = Rectangle( Point( aPageOfs.Y(), aPageOfs.X() ),
+ Size( aOutRect.GetHeight(), aOutRect.GetWidth() ) );
+ }
+
+ Link aOldLink;
+ Outliner* pOutliner = mrBase.GetDocument()->GetInternalOutliner();
+ pOutliner->Init(OUTLINERMODE_OUTLINEVIEW);
+ const sal_uInt16 nSavedOutlMode (pOutliner->GetMode());
+ const sal_Bool bSavedUpdateMode (pOutliner->GetUpdateMode());
+ const Size aSavedPaperSize (pOutliner->GetPaperSize());
+ const MapMode aSavedMapMode (pOutliner->GetRefMapMode());
+ pOutliner->SetPaperSize(aOutRect.GetSize());
+ pOutliner->SetUpdateMode(sal_True);
+
+ long nPageH = aOutRect.GetHeight();
+
+ for (sal_uInt16
+ nIndex=0,
+ nCount=mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
+ nIndex < nCount;
+ )
+ {
+ pOutliner->Clear();
+ pOutliner->SetFirstPageNumber(nIndex+1);
+
+ Paragraph* pPara = NULL;
+ sal_Int32 nH (0);
+ while (nH < nPageH && nIndex<nCount)
+ {
+ SdPage* pPage = GetFilteredPage(nIndex, PK_STANDARD, rInfo);
+ ++nIndex;
+ if (pPage == NULL)
+ continue;
+
+ SdrTextObj* pTextObj = NULL;
+ sal_uInt32 nObj (0);
+
+ while (pTextObj==NULL && nObj < pPage->GetObjCount())
+ {
+ SdrObject* pObj = pPage->GetObj(nObj++);
+ if (pObj->GetObjInventor() == SdrInventor
+ && pObj->GetObjIdentifier() == OBJ_TITLETEXT)
+ {
+ pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ }
+ }
+
+ pPara = pOutliner->GetParagraph(pOutliner->GetParagraphCount() - 1);
+
+ if (pTextObj!=NULL
+ && !pTextObj->IsEmptyPresObj()
+ && pTextObj->GetOutlinerParaObject())
+ {
+ pOutliner->AddText(*(pTextObj->GetOutlinerParaObject()));
+ }
+ else
+ pOutliner->Insert(String());
+
+ pTextObj = NULL;
+ nObj = 0;
+
+ while (pTextObj==NULL && nObj<pPage->GetObjCount())
+ {
+ SdrObject* pObj = pPage->GetObj(nObj++);
+ if (pObj->GetObjInventor() == SdrInventor
+ && pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
+ {
+ pTextObj = dynamic_cast<SdrTextObj*>(pObj);
+ }
+ }
+
+ bool bSubTitle (false);
+ if (!pTextObj)
+ {
+ bSubTitle = true;
+ pTextObj = dynamic_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TEXT)); // Untertitel vorhanden?
+ }
+
+ sal_uLong nParaCount1 = pOutliner->GetParagraphCount();
+
+ if (pTextObj!=NULL
+ && !pTextObj->IsEmptyPresObj()
+ && pTextObj->GetOutlinerParaObject())
+ {
+ pOutliner->AddText(*(pTextObj->GetOutlinerParaObject()));
+ }
+
+ if (bSubTitle )
+ {
+ const sal_Int32 nParaCount2 (pOutliner->GetParagraphCount());
+ for (sal_Int32 nPara=nParaCount1; nPara<nParaCount2; ++nPara)
+ {
+ Paragraph* pP = pOutliner->GetParagraph(nPara);
+ if (pP!=NULL && pOutliner->GetDepth((sal_uInt16)nPara) > 0)
+ pOutliner->SetDepth(pP, 0);
+ }
+ }
+
+ nH = pOutliner->GetTextHeight();
+ }
+
+ // Remove the last paragraph when that does not fit completely on
+ // the current page.
+ if (nH > nPageH && pPara!=NULL)
+ {
+ sal_uLong nCnt = pOutliner->GetAbsPos(
+ pOutliner->GetParagraph( pOutliner->GetParagraphCount() - 1 ) );
+ sal_uLong nParaPos = pOutliner->GetAbsPos( pPara );
+ nCnt -= nParaPos;
+ pPara = pOutliner->GetParagraph( ++nParaPos );
+ if ( nCnt && pPara )
+ {
+ pOutliner->Remove(pPara, nCnt);
+ --nIndex;
+ }
+ }
+
+ maPrinterPages.push_back(
+ ::boost::shared_ptr<PrinterPage>(
+ new OutlinerPrinterPage(
+ pOutliner->CreateParaObject(),
+ aMap,
+ rInfo.msTimeDate,
+ aPageOfs,
+ rInfo.mnDrawMode,
+ rInfo.meOrientation,
+ rInfo.mpPrinter->GetPaperBin())));
+ }
+
+ pOutliner->SetRefMapMode(aSavedMapMode);
+ pOutliner->SetUpdateMode(bSavedUpdateMode);
+ pOutliner->SetPaperSize(aSavedPaperSize);
+ pOutliner->Init(nSavedOutlMode);
+ }
+
+
+
+
+ /** Prepare handout pages for slides that are to be printed.
+ */
+ void PrepareHandout (PrintInfo& rInfo)
+ {
+ SdDrawDocument* pDocument = mrBase.GetDocument();
+ OSL_ASSERT(pDocument != NULL);
+ SdPage& rHandoutPage (*pDocument->GetSdPage(0, PK_HANDOUT));
+
+ const bool bScalePage (mpOptions->IsPageSize());
+
+ sal_uInt16 nPaperBin;
+ if ( ! mpOptions->IsPaperBin())
+ nPaperBin = rHandoutPage.GetPaperBin();
+ else
+ nPaperBin = rInfo.mpPrinter->GetPaperBin();
+
+ // Change orientation?
+ SdPage& rMaster (dynamic_cast<SdPage&>(rHandoutPage.TRG_GetMasterPage()));
+ rInfo.meOrientation = rMaster.GetOrientation();
+
+ const Size aPaperSize (rInfo.mpPrinter->GetPaperSize());
+ if( (rInfo.meOrientation == ORIENTATION_LANDSCAPE &&
+ (aPaperSize.Width() < aPaperSize.Height()))
+ ||
+ (rInfo.meOrientation == ORIENTATION_PORTRAIT &&
+ (aPaperSize.Width() > aPaperSize.Height()))
+ )
+ {
+ maPrintSize = awt::Size(aPaperSize.Height(), aPaperSize.Width());
+ }
+ else
+ {
+ maPrintSize = awt::Size(aPaperSize.Width(), aPaperSize.Height());
+ }
+
+ MapMode aMap (rInfo.maMap);
+ const Point aPageOfs (rInfo.mpPrinter->GetPageOffset());
+ //DrawView* pPrintView;
+
+ // aMap.SetOrigin(Point() - aPageOfs);
+
+ if ( bScalePage )
+ {
+ const Size aPageSize (rHandoutPage.GetSize());
+ const Size aPrintSize (rInfo.mpPrinter->GetOutputSize());
+
+ const double fHorz = (double) aPrintSize.Width() / aPageSize.Width();
+ const double fVert = (double) aPrintSize.Height() / aPageSize.Height();
+
+ Fraction aFract;
+ if ( fHorz < fVert )
+ aFract = Fraction(aPrintSize.Width(), aPageSize.Width());
+ else
+ aFract = Fraction(aPrintSize.Height(), aPageSize.Height());
+
+ aMap.SetScaleX(aFract);
+ aMap.SetScaleY(aFract);
+ aMap.SetOrigin(Point());
+ }
+
+ ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
+ pViewShell->WriteFrameViewData();
+
+ // Count page shapes.
+ sal_uInt32 nShapeCount (0);
+ SdrObjListIter aShapeIter (rHandoutPage);
+ while (aShapeIter.IsMore())
+ {
+ SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(aShapeIter.Next());
+ if (pPageObj)
+ ++nShapeCount;
+ }
+
+ const sal_uInt16 nPageCount = mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
+ const sal_uInt16 nHandoutPageCount = nShapeCount ? (nPageCount + nShapeCount - 1) / nShapeCount : 0;
+ pViewShell->SetPrintedHandoutPageCount( nHandoutPageCount );
+ mrBase.GetDocument()->setHandoutPageCount( nHandoutPageCount );
+
+ // Distribute pages to handout pages.
+ ::std::vector<sal_uInt16> aPageIndices;
+ std::vector<SdPage*> aPagesVector;
+ for (sal_uInt16
+ nIndex=0,
+ nCount= nPageCount,
+ nHandoutPageIndex=0;
+ nIndex <= nCount;
+ ++nIndex)
+ {
+ if (nIndex < nCount)
+ {
+ if (GetFilteredPage(nIndex, PK_STANDARD, rInfo) == NULL)
+ continue;
+ aPageIndices.push_back(nIndex);
+ }
+
+ // Create a printer page when we have found one page for each
+ // placeholder or when this is the last (and special) loop.
+ if (aPageIndices.size() == nShapeCount
+ || nIndex==nCount)
+ {
+ maPrinterPages.push_back(
+ ::boost::shared_ptr<PrinterPage>(
+ new HandoutPrinterPage(
+ nHandoutPageIndex++,
+ aPageIndices,
+ aMap,
+ rInfo.msTimeDate,
+ aPageOfs,
+ rInfo.mnDrawMode,
+ rInfo.meOrientation,
+ nPaperBin)));
+ aPageIndices.clear();
+ }
+ }
+ }
+
+
+
+
+ /** Prepare the notes pages or regular slides.
+ */
+ void PrepareStdOrNotes (
+ const PageKind ePageKind,
+ PrintInfo& rInfo)
+ {
+ OSL_ASSERT(rInfo.mpPrinter != NULL);
+
+ // Fill in page kind specific data.
+ SdDrawDocument* pDocument = mrBase.GetMainViewShell()->GetDoc();
+ if (pDocument->GetSdPageCount(ePageKind) == 0)
+ return;
+ SdPage* pRefPage = pDocument->GetSdPage(0, ePageKind);
+ rInfo.maPageSize = pRefPage->GetSize();
+
+ if ( ! SetupPaperOrientation(ePageKind, rInfo))
+ return;
+
+ MapMode aMap (rInfo.maMap);
+ // aMap.SetOrigin(Point() - rInfo.mpPrinter->GetPageOffset());
+ rInfo.maMap = aMap;
+
+ if (mpOptions->IsBooklet())
+ PrepareBooklet(ePageKind, rInfo);
+ else
+ PrepareRegularPages(ePageKind, rInfo);
+ }
+
+
+
+
+ /** Prepare slides in a non-booklet way: one slide per one to many
+ printer pages.
+ */
+ void PrepareRegularPages (
+ const PageKind ePageKind,
+ PrintInfo& rInfo)
+ {
+ ::boost::shared_ptr<ViewShell> pViewShell (mrBase.GetMainViewShell());
+ pViewShell->WriteFrameViewData();
+ Point aPtZero;
+
+ for (sal_uInt16
+ nIndex=0,
+ nCount=mrBase.GetDocument()->GetSdPageCount(PK_STANDARD);
+ nIndex < nCount;
+ ++nIndex)
+ {
+ SdPage* pPage = GetFilteredPage(nIndex, ePageKind, rInfo);
+ if (pPage == NULL)
+ continue;
+
+ MapMode aMap (rInfo.maMap);
+ // Kann sich die Seitengroesse geaendert haben?
+ const Size aPageSize = pPage->GetSize();
+
+ if (mpOptions->IsPageSize())
+ {
+ const double fHorz ((double) rInfo.maPrintSize.Width() / aPageSize.Width());
+ const double fVert ((double) rInfo.maPrintSize.Height() / aPageSize.Height());
+
+ Fraction aFract;
+ if (fHorz < fVert)
+ aFract = Fraction(rInfo.maPrintSize.Width(), aPageSize.Width());
+ else
+ aFract = Fraction(rInfo.maPrintSize.Height(), aPageSize.Height());
+
+ aMap.SetScaleX(aFract);
+ aMap.SetScaleY(aFract);
+ aMap.SetOrigin(Point());
+ }
+
+ if (mpOptions->IsPrintPageName())
+ {
+ rInfo.msPageString = pPage->GetName();
+ rInfo.msPageString += ::rtl::OUString(sal_Unicode(' '));
+ }
+ else
+ rInfo.msPageString = ::rtl::OUString();
+ rInfo.msPageString += rInfo.msTimeDate;
+
+ long aPageWidth = aPageSize.Width() - pPage->GetLftBorder() - pPage->GetRgtBorder();
+ long aPageHeight = aPageSize.Height() - pPage->GetUppBorder() - pPage->GetLwrBorder();
+ // Bugfix zu 44530:
+ // Falls implizit umgestellt wurde (Landscape/Portrait)
+ // wird dies beim Kacheln, bzw. aufteilen (Poster) beruecksichtigt
+ sal_Bool bSwitchPageSize = sal_False;
+ if( ( rInfo.maPrintSize.Width() > rInfo.maPrintSize.Height()
+ && aPageWidth < aPageHeight )
+ || ( rInfo.maPrintSize.Width() < rInfo.maPrintSize.Height()
+ && aPageWidth > aPageHeight ) )
+ {
+ bSwitchPageSize = sal_True;
+ const sal_Int32 nTmp (rInfo.maPrintSize.Width());
+ rInfo.maPrintSize.Width() = rInfo.maPrintSize.Height();
+ rInfo.maPrintSize.Height() = nTmp;
+ }
+
+ if (mpOptions->IsTilePage()
+ && aPageWidth < rInfo.maPrintSize.Width()
+ && aPageHeight < rInfo.maPrintSize.Height())
+ {
+ // Put multiple slides on one printer page.
+ PrepareTiledPage(nIndex, *pPage, ePageKind, rInfo);
+ }
+ else
+ {
+ rInfo.maMap = aMap;
+ PrepareScaledPage(nIndex, *pPage, ePageKind, rInfo);
+ }
+ }
+ }
+
+
+
+
+ /** Put two slides on one printer page.
+ */
+ void PrepareBooklet (
+ const PageKind ePageKind,
+ const PrintInfo& rInfo)
+ {
+ MapMode aStdMap (rInfo.maMap);
+ Point aOffset;
+ Size aPrintSize_2 (rInfo.maPrintSize);
+ Size aPageSize_2 (rInfo.maPageSize);
+
+ if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
+ aPrintSize_2.Width() >>= 1;
+ else
+ aPrintSize_2.Height() >>= 1;
+
+ const double fPageWH = (double) aPageSize_2.Width() / aPageSize_2.Height();
+ const double fPrintWH = (double) aPrintSize_2.Width() / aPrintSize_2.Height();
+
+ if( fPageWH < fPrintWH )
+ {
+ aPageSize_2.Width() = (long) ( aPrintSize_2.Height() * fPageWH );
+ aPageSize_2.Height()= aPrintSize_2.Height();
+ }
+ else
+ {
+ aPageSize_2.Width() = aPrintSize_2.Width();
+ aPageSize_2.Height() = (long) ( aPrintSize_2.Width() / fPageWH );
+ }
+
+ MapMode aMap (rInfo.maMap);
+ aMap.SetScaleX( Fraction( aPageSize_2.Width(), rInfo.maPageSize.Width() ) );
+ aMap.SetScaleY( Fraction( aPageSize_2.Height(), rInfo.maPageSize.Height() ) );
+
+ // calculate adjusted print size
+ const Size aAdjustedPrintSize (OutputDevice::LogicToLogic(
+ rInfo.maPrintSize,
+ aStdMap,
+ aMap));
+
+ if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
+ {
+ aOffset.X() = ( ( aAdjustedPrintSize.Width() >> 1 ) - rInfo.maPageSize.Width() ) >> 1;
+ aOffset.Y() = ( aAdjustedPrintSize.Height() - rInfo.maPageSize.Height() ) >> 1;
+ }
+ else
+ {
+ aOffset.X() = ( aAdjustedPrintSize.Width() - rInfo.maPageSize.Width() ) >> 1;
+ aOffset.Y() = ( ( aAdjustedPrintSize.Height() >> 1 ) - rInfo.maPageSize.Height() ) >> 1;
+ }
+
+ // create vector of pages to print
+ ::std::vector< sal_uInt16 > aPageVector;
+ for (sal_uInt16
+ nIndex=0,
+ nCount=mrBase.GetDocument()->GetSdPageCount(ePageKind);
+ nIndex < nCount;
+ ++nIndex)
+ {
+ SdPage* pPage = GetFilteredPage(nIndex, ePageKind, rInfo);
+ if (pPage != NULL)
+ aPageVector.push_back(nIndex);
+ }
+
+ // create pairs of pages to print on each page
+ typedef ::std::vector< ::std::pair< sal_uInt16, sal_uInt16 > > PairVector;
+ PairVector aPairVector;
+ if ( ! aPageVector.empty())
+ {
+ sal_uInt32 nFirstIndex = 0, nLastIndex = aPageVector.size() - 1;
+
+ if( aPageVector.size() & 1 )
+ aPairVector.push_back( ::std::make_pair( (sal_uInt16) 65535, aPageVector[ nFirstIndex++ ] ) );
+ else
+ aPairVector.push_back( ::std::make_pair( aPageVector[ nLastIndex-- ], aPageVector[ nFirstIndex++ ] ) );
+
+ while( nFirstIndex < nLastIndex )
+ {
+ if( nFirstIndex & 1 )
+ aPairVector.push_back( ::std::make_pair( aPageVector[ nFirstIndex++ ], aPageVector[ nLastIndex-- ] ) );
+ else
+ aPairVector.push_back( ::std::make_pair( aPageVector[ nLastIndex-- ], aPageVector[ nFirstIndex++ ] ) );
+ }
+ }
+
+ for (sal_uInt32
+ nIndex=0,
+ nCount=aPairVector.size();
+ nIndex < nCount;
+ ++nIndex)
+ {
+ const bool bIsIndexOdd (nIndex & 1);
+ if ((!bIsIndexOdd && mpOptions->IsPrintFrontPage())
+ || (bIsIndexOdd && mpOptions->IsPrintBackPage()))
+ {
+ const ::std::pair<sal_uInt16, sal_uInt16> aPair (aPairVector[nIndex]);
+ Point aSecondOffset (aOffset);
+ if (rInfo.meOrientation == ORIENTATION_LANDSCAPE)
+ aSecondOffset.X() += aAdjustedPrintSize.Width() / 2;
+ else
+ aSecondOffset.Y() += aAdjustedPrintSize.Height() / 2;
+ maPrinterPages.push_back(
+ ::boost::shared_ptr<PrinterPage>(
+ new BookletPrinterPage(
+ aPair.first,
+ aPair.second,
+ aOffset,
+ aSecondOffset,
+ ePageKind,
+ aMap,
+ rInfo.mbPrintMarkedOnly,
+ rInfo.mnDrawMode,
+ rInfo.meOrientation,
+ rInfo.mpPrinter->GetPaperBin())));
+
+ }
+ }
+ }
+
+
+
+
+ /** Print one slide multiple times on one printer page so that the whole
+ printer page is covered.
+ */
+ void PrepareTiledPage (
+ const sal_Int32 nPageIndex,
+ const SdPage& rPage,
+ const PageKind ePageKind,
+ const PrintInfo& rInfo)
+ {
+ sal_uInt16 nPaperBin;
+ if ( ! mpOptions->IsPaperBin())
+ nPaperBin = rPage.GetPaperBin();
+ else
+ nPaperBin = rInfo.mpPrinter->GetPaperBin();
+
+ maPrinterPages.push_back(
+ ::boost::shared_ptr<PrinterPage>(
+ new TiledPrinterPage(
+ sal::static_int_cast<sal_uInt16>(nPageIndex),
+ ePageKind,
+ 500,
+ rInfo.mbPrintMarkedOnly,
+ rInfo.msPageString,
+ rInfo.mpPrinter->GetPageOffset(),
+ rInfo.mnDrawMode,
+ rInfo.meOrientation,
+ nPaperBin)));
+ }
+
+
+
+ /** Print one standard slide or notes page on one to many printer
+ pages. More than on printer page is used when the slide is larger
+ than the printable area.
+ */
+ void PrepareScaledPage (
+ const sal_Int32 nPageIndex,
+ const SdPage& rPage,
+ const PageKind ePageKind,
+ const PrintInfo& rInfo)
+ {
+ const Point aPageOffset (rInfo.mpPrinter->GetPageOffset());
+
+ sal_uInt16 nPaperBin;
+ if ( ! mpOptions->IsPaperBin())
+ nPaperBin = rPage.GetPaperBin();
+ else
+ nPaperBin = rInfo.mpPrinter->GetPaperBin();
+
+ // For pages larger then the printable area there
+ // are three options:
+ // 1. Scale down to the page to the printable area.
+ // 2. Print only the upper left part of the page
+ // (without the unprintable borders).
+ // 3. Split the page into parts of the size of the
+ // printable area.
+ const bool bScalePage (mpOptions->IsPageSize());
+ const bool bCutPage (mpOptions->IsCutPage());
+ MapMode aMap (rInfo.maMap);
+ if (bScalePage || bCutPage)
+ {
+ // Handle 1 and 2.
+
+ // if CutPage is set then do not move it, otherwise move the
+ // scaled page to printable area
+ #if 0
+ if (bCutPage)
+ aMap.SetOrigin(Point(-aPageOffset.X(), -aPageOffset.Y()));
+ else
+ aMap.SetOrigin(Point(0,0));
+ #endif
+ maPrinterPages.push_back(
+ ::boost::shared_ptr<PrinterPage>(
+ new RegularPrinterPage(
+ sal::static_int_cast<sal_uInt16>(nPageIndex),
+ ePageKind,
+ aMap,
+ rInfo.mbPrintMarkedOnly,
+ rInfo.msPageString,
+ aPageOffset,
+ rInfo.mnDrawMode,
+ rInfo.meOrientation,
+ nPaperBin)));
+ }
+ else
+ {
+ // Handle 3. Print parts of the page in the size of the
+ // printable area until the whole page is covered.
+
+ // keep the page content at its position if it fits, otherwise
+ // move it to the printable area
+ const long nPageWidth (
+ rInfo.maPageSize.Width() - rPage.GetLftBorder() - rPage.GetRgtBorder());
+ const long nPageHeight (
+ rInfo.maPageSize.Height() - rPage.GetUppBorder() - rPage.GetLwrBorder());
+ #if 0
+ Point aOrigin (
+ nPageWidth < rInfo.maPrintSize.Width() ? -aPageOffset.X() : 0,
+ nPageHeight < rInfo.maPrintSize.Height() ? -aPageOffset.Y() : 0);
+ #else
+ Point aOrigin ( 0, 0 );
+ #endif
+ for (Point aPageOrigin = aOrigin;
+ -aPageOrigin.Y()<nPageHeight;
+ aPageOrigin.Y() -= rInfo.maPrintSize.Height())
+ {
+ for (aPageOrigin.X()=aOrigin.X();
+ -aPageOrigin.X()<nPageWidth;
+ aPageOrigin.X() -= rInfo.maPrintSize.Width())
+ {
+ aMap.SetOrigin(aPageOrigin);
+ maPrinterPages.push_back(
+ ::boost::shared_ptr<PrinterPage>(
+ new RegularPrinterPage(
+ sal::static_int_cast<sal_uInt16>(nPageIndex),
+ ePageKind,
+ aMap,
+ rInfo.mbPrintMarkedOnly,
+ rInfo.msPageString,
+ aPageOffset,
+ rInfo.mnDrawMode,
+ rInfo.meOrientation,
+ nPaperBin)));
+ }
+ }
+ }
+ }
+};
+
+
+
+
+//===== DocumentRenderer ======================================================
+
+DocumentRenderer::DocumentRenderer (ViewShellBase& rBase)
+ : DocumentRendererInterfaceBase(m_aMutex),
+ mpImpl(new Implementation(rBase))
+{
+}
+
+
+
+
+DocumentRenderer::~DocumentRenderer (void)
+{
+}
+
+
+
+
+//----- XRenderable -----------------------------------------------------------
+
+sal_Int32 SAL_CALL DocumentRenderer::getRendererCount (
+ const css::uno::Any& aSelection,
+ const css::uno::Sequence<css::beans::PropertyValue >& rOptions)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ (void)aSelection;
+ mpImpl->ProcessProperties(rOptions);
+ return mpImpl->GetPrintPageCount();
+}
+
+
+
+
+Sequence<beans::PropertyValue> SAL_CALL DocumentRenderer::getRenderer (
+ sal_Int32 nRenderer,
+ const css::uno::Any& rSelection,
+ const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ (void)nRenderer;
+ (void)rSelection;
+ mpImpl->ProcessProperties(rOptions);
+ return mpImpl->GetProperties(rOptions);
+}
+
+
+
+
+void SAL_CALL DocumentRenderer::render (
+ sal_Int32 nRenderer,
+ const css::uno::Any& rSelection,
+ const css::uno::Sequence<css::beans::PropertyValue>& rOptions)
+ throw (css::lang::IllegalArgumentException, css::uno::RuntimeException)
+{
+ (void)rSelection;
+ mpImpl->ProcessProperties(rOptions);
+ mpImpl->PrintPage(nRenderer);
+}
+
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/DocumentRenderer.hrc b/sd/source/ui/view/DocumentRenderer.hrc
new file mode 100755
index 000000000000..aad07d909def
--- /dev/null
+++ b/sd/source/ui/view/DocumentRenderer.hrc
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#define _STR_IMPRESS_PRINT_UI_OPTIONS 32001
+#define _STR_IMPRESS_PRINT_UI_GROUP_NAME 1
+#define _STR_IMPRESS_PRINT_UI_PRINT_CONTENT 2
+#define _STR_IMPRESS_PRINT_UI_PRINT_GROUP 3
+#define _STR_IMPRESS_PRINT_UI_CONTENT 4
+#define _STR_IMPRESS_PRINT_UI_CONTENT_CHOICES 6
+#define _STR_IMPRESS_PRINT_UI_SLIDESPERPAGE 7
+#define _STR_IMPRESS_PRINT_UI_SLIDESPERPAGE_CHOICES 8
+#define _STR_IMPRESS_PRINT_UI_ORDER 10
+#define _STR_IMPRESS_PRINT_UI_ORDER_CHOICES 11
+#define _STR_IMPRESS_PRINT_UI_INCLUDE_CONTENT 13
+#define _STR_IMPRESS_PRINT_UI_IS_PRINT_NAME 14
+#define _STR_IMPRESS_PRINT_UI_IS_PRINT_DATE 16
+#define _STR_IMPRESS_PRINT_UI_IS_PRINT_TIME 18
+#define _STR_IMPRESS_PRINT_UI_IS_PRINT_HIDDEN 20
+
+#define _STR_IMPRESS_PRINT_UI_OUTPUT_OPTIONS_GROUP 22
+#define _STR_IMPRESS_PRINT_UI_QUALITY 23
+#define _STR_IMPRESS_PRINT_UI_QUALITY_CHOICES 24
+#define _STR_IMPRESS_PRINT_UI_PAGE_OPTIONS 26
+#define _STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES 27
+#define _STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES_DRAW 28
+#define _STR_IMPRESS_PRINT_UI_BROCHURE 30
+#define _STR_IMPRESS_PRINT_UI_PAGE_SIDES 32
+#define _STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE 33
+#define _STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE_LIST 35
+#define _STR_IMPRESS_PRINT_UI_PAPER_TRAY_GROUP 37
+#define _STR_IMPRESS_PRINT_UI_PAPER_TRAY 38
+
+#define _STR_IMPRESS_PRINT_UI_PAGE_RANGE 40
+#define _STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE 41
+#define _STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE 43
+
+#define _STR_DRAW_PRINT_UI_IS_PRINT_NAME 44
+
diff --git a/sd/source/ui/view/DocumentRenderer.src b/sd/source/ui/view/DocumentRenderer.src
new file mode 100755
index 000000000000..df4e2a30de02
--- /dev/null
+++ b/sd/source/ui/view/DocumentRenderer.src
@@ -0,0 +1,202 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "app.hrc"
+#include "DocumentRenderer.hrc"
+
+Resource _STR_IMPRESS_PRINT_UI_OPTIONS
+{
+ String _STR_IMPRESS_PRINT_UI_GROUP_NAME
+ {
+ Text [en-US] = "%PRODUCTNAME %s";
+ };
+ String _STR_IMPRESS_PRINT_UI_PRINT_CONTENT
+ {
+ Text [ en-US ] = "Print content";
+ };
+ String _STR_IMPRESS_PRINT_UI_PRINT_GROUP
+ {
+ Text [ en-US ] = "Print";
+ };
+ String _STR_IMPRESS_PRINT_UI_CONTENT
+ {
+ Text [ en-US ] = "Document";
+ };
+ StringArray _STR_IMPRESS_PRINT_UI_CONTENT_CHOICES
+ {
+ ItemList [ en-US ] =
+ {
+ < "Slides" ; > ;
+ < "Handouts" ; > ;
+ < "Notes" ; > ;
+ < "Outline" ; > ;
+ };
+ };
+ String _STR_IMPRESS_PRINT_UI_SLIDESPERPAGE
+ {
+ Text [ en-US ] = "Slides per page" ;
+ };
+ StringArray _STR_IMPRESS_PRINT_UI_SLIDESPERPAGE_CHOICES
+ {
+ ItemList [ en-US ] =
+ {
+ < "Default" ; > ;
+ < "1" ; > ;
+ < "2" ; > ;
+ < "3" ; > ;
+ < "4" ; > ;
+ < "6" ; > ;
+ < "9" ; > ;
+ };
+ };
+ String _STR_IMPRESS_PRINT_UI_ORDER
+ {
+ Text [ en-US ] = "Order" ;
+ };
+ StringArray _STR_IMPRESS_PRINT_UI_ORDER_CHOICES
+ {
+ ItemList [ en-US ] =
+ {
+ < "Left to right, then down" ; > ;
+ < "Top to bottom, then right" ; > ;
+ };
+ };
+ String _STR_IMPRESS_PRINT_UI_INCLUDE_CONTENT
+ {
+ Text [ en-US ] = "~Contents";
+ };
+ String _STR_IMPRESS_PRINT_UI_IS_PRINT_NAME
+ {
+ Text [ en-US ] = "~Slide name";
+ };
+ String _STR_DRAW_PRINT_UI_IS_PRINT_NAME
+ {
+ Text [ en-US ] = "P~age name";
+ };
+ String _STR_IMPRESS_PRINT_UI_IS_PRINT_DATE
+ {
+ Text [ en-US ] = "~Date and time";
+ };
+ String _STR_IMPRESS_PRINT_UI_IS_PRINT_HIDDEN
+ {
+ Text [ en-US ] = "Hidden pages";
+ };
+ String _STR_IMPRESS_PRINT_UI_OUTPUT_OPTIONS_GROUP
+ {
+ Text [ en-US ] = "Output options";
+ };
+ String _STR_IMPRESS_PRINT_UI_QUALITY
+ {
+ Text [ en-US ] = "Color";
+ };
+ StringArray _STR_IMPRESS_PRINT_UI_QUALITY_CHOICES
+ {
+ ItemList [ en-US ] =
+ {
+ < "Original colors" ; > ;
+ < "Grayscale" ; > ;
+ < "Black & white" ; > ;
+ };
+ };
+ String _STR_IMPRESS_PRINT_UI_PAGE_OPTIONS
+ {
+ Text [ en-US ] = "~Size";
+ };
+ StringArray _STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES
+ {
+ ItemList [ en-US ] =
+ {
+ < "Original size" ; > ;
+ < "Fit to printable page" ; > ;
+ < "Distribute on multiple sheets of paper" ; > ;
+ < "Tile sheet of paper with repeated slides" ; > ;
+ };
+ };
+ StringArray _STR_IMPRESS_PRINT_UI_PAGE_OPTIONS_CHOICES_DRAW
+ {
+ ItemList [ en-US ] =
+ {
+ < "Original size" ; > ;
+ < "Fit to printable page" ; > ;
+ < "Distribute on multiple sheets of paper" ; > ;
+ < "Tile sheet of paper with repeated pages" ; > ;
+ };
+ };
+ String _STR_IMPRESS_PRINT_UI_BROCHURE
+ {
+ Text [en-US] = "Brochure";
+ };
+ String _STR_IMPRESS_PRINT_UI_PAGE_SIDES
+ {
+ Text [ en-US ] = "Page sides";
+ };
+ String _STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE
+ {
+ Text [ en-US ] = "Include";
+ };
+ StringArray _STR_IMPRESS_PRINT_UI_BROCHURE_INCLUDE_LIST
+ {
+ ItemList [ en-US ] =
+ {
+ < "All pages" ; > ;
+ < "Front sides / right pages" ; > ;
+ < "Back sides / left pages" ; > ;
+ };
+ };
+
+ String _STR_IMPRESS_PRINT_UI_PAPER_TRAY_GROUP
+ {
+ Text [ en-US ] = "Paper tray";
+ };
+ String _STR_IMPRESS_PRINT_UI_PAPER_TRAY
+ {
+ Text [ en-US ] = "~Use only paper tray from printer preferences";
+ };
+ String _STR_IMPRESS_PRINT_UI_PAGE_RANGE
+ {
+ Text [en-US] = "Print range";
+ };
+ StringArray _STR_IMPRESS_PRINT_UI_PAGE_RANGE_CHOICE
+ {
+ ItemList [ en-US ] =
+ {
+ < "~All slides"; >;
+ < "~Slides"; >;
+ < "Se~lection"; >;
+ };
+ };
+
+ StringArray _STR_DRAW_PRINT_UI_PAGE_RANGE_CHOICE
+ {
+ ItemList [ en-US ] =
+ {
+ < "~All pages"; >;
+ < "Pa~ges"; >;
+ < "Se~lection"; >;
+ };
+ };
+};
diff --git a/sd/source/ui/view/FormShellManager.cxx b/sd/source/ui/view/FormShellManager.cxx
new file mode 100644
index 000000000000..448df20b50cd
--- /dev/null
+++ b/sd/source/ui/view/FormShellManager.cxx
@@ -0,0 +1,393 @@
+/*************************************************************************
+ *
+ * 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 "FormShellManager.hxx"
+
+#include "EventMultiplexer.hxx"
+#include "ViewShell.hxx"
+#include "ViewShellBase.hxx"
+#include "ViewShellManager.hxx"
+#include "Window.hxx"
+#include <svx/fmshell.hxx>
+
+namespace sd {
+
+namespace {
+
+/** This factory is responsible for creating and deleting the FmFormShell.
+*/
+class FormShellManagerFactory
+ : public ::sd::ShellFactory<SfxShell>
+{
+public:
+ FormShellManagerFactory (ViewShell& rViewShell, FormShellManager& rManager);
+ virtual FmFormShell* CreateShell (ShellId nId, ::Window* pParentWindow, FrameView* pFrameView);
+ virtual void ReleaseShell (SfxShell* pShell);
+
+private:
+ ::sd::ViewShell& mrViewShell;
+ FormShellManager& mrFormShellManager;
+};
+
+} // end of anonymous namespace
+
+
+FormShellManager::FormShellManager (ViewShellBase& rBase)
+ : mrBase(rBase),
+ mpFormShell(NULL),
+ mbFormShellAboveViewShell(false),
+ mpSubShellFactory(),
+ mbIsMainViewChangePending(false),
+ mpMainViewShellWindow(NULL)
+{
+ // Register at the EventMultiplexer to be informed about changes in the
+ // center pane.
+ Link aLink (LINK(this, FormShellManager, ConfigurationUpdateHandler));
+ mrBase.GetEventMultiplexer()->AddEventListener(
+ aLink,
+ sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
+ | sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
+ | sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
+
+ RegisterAtCenterPane();
+}
+
+
+
+
+FormShellManager::~FormShellManager (void)
+{
+ SetFormShell(NULL);
+ UnregisterAtCenterPane();
+
+ // Unregister from the EventMultiplexer.
+ Link aLink (LINK(this, FormShellManager, ConfigurationUpdateHandler));
+ mrBase.GetEventMultiplexer()->RemoveEventListener(aLink);
+
+ if (mpSubShellFactory.get() != NULL)
+ {
+ ViewShell* pShell = mrBase.GetMainViewShell().get();
+ if (pShell != NULL)
+ mrBase.GetViewShellManager()->RemoveSubShellFactory(pShell,mpSubShellFactory);
+ }
+}
+
+
+
+
+void FormShellManager::SetFormShell (FmFormShell* pFormShell)
+{
+ if (mpFormShell != pFormShell)
+ {
+ // Disconnect from the old form shell.
+ if (mpFormShell != NULL)
+ {
+ mpFormShell->SetControlActivationHandler(Link());
+ EndListening(*mpFormShell);
+ mpFormShell->SetView(NULL);
+ }
+
+ mpFormShell = pFormShell;
+
+ // Connect to the new form shell.
+ if (mpFormShell != NULL)
+ {
+ mpFormShell->SetControlActivationHandler(
+ LINK(
+ this,
+ FormShellManager,
+ FormControlActivated));
+ StartListening(*mpFormShell);
+
+ ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
+ if (pMainViewShell != NULL)
+ {
+ // Prevent setting the view twice at the FmFormShell.
+ FmFormView* pFormView = static_cast<FmFormView*>(pMainViewShell->GetView());
+ if (mpFormShell->GetFormView() != pFormView)
+ mpFormShell->SetView(pFormView);
+ }
+ }
+
+ // Tell the ViewShellManager where on the stack to place the form shell.
+ mrBase.GetViewShellManager()->SetFormShell(
+ mrBase.GetMainViewShell().get(),
+ mpFormShell,
+ mbFormShellAboveViewShell);
+ }
+}
+
+
+
+
+FmFormShell* FormShellManager::GetFormShell (void)
+{
+ return mpFormShell;
+}
+
+
+
+
+void FormShellManager::RegisterAtCenterPane (void)
+{
+ do
+ {
+ ViewShell* pShell = mrBase.GetMainViewShell().get();
+ if (pShell == NULL)
+ break;
+
+ // No form shell for the slide sorter. Besides that it is not
+ // necessary, using both together results in crashes.
+ if (pShell->GetShellType() == ViewShell::ST_SLIDE_SORTER)
+ break;
+
+ mpMainViewShellWindow = pShell->GetActiveWindow();
+ if (mpMainViewShellWindow == NULL)
+ break;
+
+ // Register at the window to get informed when to move the form
+ // shell to the bottom of the shell stack.
+ mpMainViewShellWindow->AddEventListener(
+ LINK(
+ this,
+ FormShellManager,
+ WindowEventHandler));
+
+ // Create a shell factory and with it activate the form shell.
+ OSL_ASSERT(mpSubShellFactory.get()==NULL);
+ mpSubShellFactory.reset(new FormShellManagerFactory(*pShell, *this));
+ mrBase.GetViewShellManager()->AddSubShellFactory(pShell,mpSubShellFactory);
+ mrBase.GetViewShellManager()->ActivateSubShell(*pShell, RID_FORMLAYER_TOOLBOX);
+ }
+ while (false);
+}
+
+
+
+
+void FormShellManager::UnregisterAtCenterPane (void)
+{
+ do
+ {
+ if (mpMainViewShellWindow != NULL)
+ {
+ // Unregister from the window.
+ mpMainViewShellWindow->RemoveEventListener(
+ LINK(
+ this,
+ FormShellManager,
+ WindowEventHandler));
+ mpMainViewShellWindow = NULL;
+ }
+
+ // Unregister form at the form shell.
+ SetFormShell(NULL);
+
+ // Deactivate the form shell and destroy the shell factory.
+ ViewShell* pShell = mrBase.GetMainViewShell().get();
+ if (pShell != NULL)
+ {
+ mrBase.GetViewShellManager()->DeactivateSubShell(*pShell, RID_FORMLAYER_TOOLBOX);
+ mrBase.GetViewShellManager()->RemoveSubShellFactory(pShell, mpSubShellFactory);
+ }
+
+ mpSubShellFactory.reset();
+ }
+ while (false);
+}
+
+
+
+
+IMPL_LINK(FormShellManager, FormControlActivated, FmFormShell*, EMPTYARG)
+{
+ // The form shell has been actived. To give it priority in reacting to
+ // slot calls the form shell is moved to the top of the object bar shell
+ // stack.
+ ViewShell* pShell = mrBase.GetMainViewShell().get();
+ if (pShell!=NULL && !mbFormShellAboveViewShell)
+ {
+ mbFormShellAboveViewShell = true;
+
+ ViewShellManager::UpdateLock aLock (mrBase.GetViewShellManager());
+ mrBase.GetViewShellManager()->SetFormShell(pShell,mpFormShell,mbFormShellAboveViewShell);
+ }
+
+ return 0;
+}
+
+
+
+
+IMPL_LINK(FormShellManager, ConfigurationUpdateHandler, sd::tools::EventMultiplexerEvent*, pEvent)
+{
+ switch (pEvent->meEventId)
+ {
+ case sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
+ UnregisterAtCenterPane();
+ break;
+
+ case sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
+ mbIsMainViewChangePending = true;
+ break;
+
+ case sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
+ if (mbIsMainViewChangePending)
+ {
+ mbIsMainViewChangePending = false;
+ RegisterAtCenterPane();
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+
+
+
+IMPL_LINK(FormShellManager, WindowEventHandler, VclWindowEvent*, pEvent)
+{
+ if (pEvent != NULL)
+ {
+ switch (pEvent->GetId())
+ {
+ case VCLEVENT_WINDOW_GETFOCUS:
+ {
+ // The window of the center pane got the focus. Therefore
+ // the form shell is moved to the bottom of the object bar
+ // stack.
+ ViewShell* pShell = mrBase.GetMainViewShell().get();
+ if (pShell!=NULL && mbFormShellAboveViewShell)
+ {
+ mbFormShellAboveViewShell = false;
+ ViewShellManager::UpdateLock aLock (mrBase.GetViewShellManager());
+ mrBase.GetViewShellManager()->SetFormShell(
+ pShell,
+ mpFormShell,
+ mbFormShellAboveViewShell);
+ }
+ }
+ break;
+
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ // We follow the sloppy focus policy. Losing the focus is
+ // ignored. We wait for the focus to be placed either in
+ // the window or the form shell. The later, however, is
+ // notified over the FormControlActivated handler, not this
+ // one.
+ break;
+
+ case VCLEVENT_OBJECT_DYING:
+ mpMainViewShellWindow = NULL;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+
+
+
+void FormShellManager::Notify(SfxBroadcaster&, const SfxHint& rHint)
+{
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if (pSimpleHint!=NULL && pSimpleHint->GetId()==SFX_HINT_DYING)
+ {
+ // If all goes well this listener is called after the
+ // FormShellManager was notified about the dying form shell by the
+ // FormShellManagerFactory.
+ OSL_ASSERT(mpFormShell==NULL);
+ if (mpFormShell != NULL)
+ {
+ mpFormShell = NULL;
+ mrBase.GetViewShellManager()->SetFormShell(
+ mrBase.GetMainViewShell().get(),
+ NULL,
+ false);
+ }
+ }
+}
+
+
+
+
+
+//===== FormShellManagerFactory ===============================================
+
+namespace {
+
+FormShellManagerFactory::FormShellManagerFactory (
+ ::sd::ViewShell& rViewShell,
+ FormShellManager& rManager)
+ : mrViewShell(rViewShell),
+ mrFormShellManager(rManager)
+{
+}
+
+
+
+
+FmFormShell* FormShellManagerFactory::CreateShell (
+ ::sd::ShellId nId,
+ ::Window*,
+ ::sd::FrameView*)
+{
+ FmFormShell* pShell = NULL;
+
+ ::sd::View* pView = mrViewShell.GetView();
+ if (nId == RID_FORMLAYER_TOOLBOX)
+ {
+ pShell = new FmFormShell(&mrViewShell.GetViewShellBase(), pView);
+ mrFormShellManager.SetFormShell(pShell);
+ }
+
+ return pShell;
+}
+
+
+
+
+void FormShellManagerFactory::ReleaseShell (SfxShell* pShell)
+{
+ if (pShell != NULL)
+ {
+ mrFormShellManager.SetFormShell(NULL);
+ delete pShell;
+ }
+}
+
+} // end of anonymous namespace
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/GraphicObjectBar.cxx b/sd/source/ui/view/GraphicObjectBar.cxx
new file mode 100755
index 000000000000..1150659a59ce
--- /dev/null
+++ b/sd/source/ui/view/GraphicObjectBar.cxx
@@ -0,0 +1,185 @@
+/*************************************************************************
+ *
+ * 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 "GraphicObjectBar.hxx"
+
+#include <limits.h>
+#include <vcl/msgbox.hxx>
+#include <svl/whiter.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/shell.hxx>
+#include <svx/svxids.hrc>
+#include <sfx2/request.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/grfflt.hxx>
+#include <svl/aeitem.hxx>
+#include <svx/grafctrl.hxx>
+
+
+#include <sfx2/objface.hxx>
+
+#include "app.hrc"
+#include "res_bmp.hrc"
+#include "glob.hrc"
+#include "strings.hrc"
+#include "DrawDocShell.hxx"
+#include "ViewShell.hxx"
+#include "Window.hxx"
+#include "drawview.hxx"
+#include "sdresid.hxx"
+#include "drawdoc.hxx"
+
+using namespace sd;
+#define GraphicObjectBar
+#include "sdslots.hxx"
+
+namespace sd {
+
+
+
+// -----------------------
+// - GraphicObjectBar -
+// -----------------------
+
+SFX_IMPL_INTERFACE( GraphicObjectBar, SfxShell, SdResId( STR_GRAFOBJECTBARSHELL ) )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+TYPEINIT1( GraphicObjectBar, SfxShell );
+
+// -----------------------------------------------------------------------------
+
+GraphicObjectBar::GraphicObjectBar (
+ ViewShell* pSdViewShell,
+ ::sd::View* pSdView )
+ : SfxShell (pSdViewShell->GetViewShell()),
+ mpView ( pSdView ),
+ mpViewSh ( pSdViewShell ),
+ nMappedSlotFilter ( SID_GRFFILTER_INVERT )
+{
+ DrawDocShell* pDocShell = mpViewSh->GetDocSh();
+
+ SetPool( &pDocShell->GetPool() );
+ SetUndoManager( pDocShell->GetUndoManager() );
+ SetRepeatTarget( mpView );
+ SetHelpId( SD_IF_SDDRAWGRAFOBJECTBAR );
+ SetName( String( RTL_CONSTASCII_USTRINGPARAM( "Graphic objectbar" )));
+}
+
+// -----------------------------------------------------------------------------
+
+GraphicObjectBar::~GraphicObjectBar()
+{
+ SetRepeatTarget( NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObjectBar::GetAttrState( SfxItemSet& rSet )
+{
+ if( mpView )
+ SvxGrafAttrHelper::GetGrafAttrState( rSet, *mpView );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObjectBar::Execute( SfxRequest& rReq )
+{
+ if( mpView )
+ {
+ SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *mpView );
+ Invalidate();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObjectBar::GetFilterState( SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+ sal_Bool bEnable = sal_False;
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) )
+ bEnable = sal_True;
+ }
+
+ if( !bEnable )
+ SvxGraphicFilter::DisableGraphicFilterSlots( rSet );
+}
+
+// -----------------------------------------------------------------------------
+
+void GraphicObjectBar::ExecuteFilter( SfxRequest& rReq )
+{
+ const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
+ {
+ GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() );
+
+ if( SVX_GRAPHICFILTER_ERRCODE_NONE ==
+ SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) )
+ {
+ SdrPageView* pPageView = mpView->GetSdrPageView();
+
+ if( pPageView )
+ {
+ SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone();
+ String aStr( mpView->GetDescriptionOfMarkedObjects() );
+
+ aStr.Append( sal_Unicode(' ') );
+ aStr.Append( String( SdResId( STR_UNDO_GRAFFILTER ) ) );
+ mpView->BegUndo( aStr );
+ pFilteredObj->SetGraphicObject( aFilterObj );
+ ::sd::View* const pView = mpView;
+ pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj );
+ pView->EndUndo();
+ return;
+ }
+ }
+ }
+ }
+
+ Invalidate();
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/GraphicViewShellBase.cxx b/sd/source/ui/view/GraphicViewShellBase.cxx
new file mode 100755
index 000000000000..890620b40341
--- /dev/null
+++ b/sd/source/ui/view/GraphicViewShellBase.cxx
@@ -0,0 +1,132 @@
+/*************************************************************************
+ *
+ * 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 "GraphicViewShellBase.hxx"
+
+#include "GraphicDocShell.hxx"
+#include "sdresid.hxx"
+#include "strings.hrc"
+#include "app.hrc"
+#include "framework/DrawModule.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include <sfx2/request.hxx>
+
+namespace sd {
+
+TYPEINIT1(GraphicViewShellBase, ViewShellBase);
+
+// We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
+// new GraphicViewShellBase object has been constructed.
+
+SfxViewFactory* GraphicViewShellBase::pFactory;
+SfxViewShell* __EXPORT GraphicViewShellBase::CreateInstance (
+ SfxViewFrame *pFrame, SfxViewShell *pOldView)
+{
+ GraphicViewShellBase* pBase = new GraphicViewShellBase(pFrame, pOldView);
+ pBase->LateInit(framework::FrameworkHelper::msDrawViewURL);
+ return pBase;
+}
+void GraphicViewShellBase::RegisterFactory( sal_uInt16 nPrio )
+{
+ pFactory = new SfxViewFactory(
+ &CreateInstance,&InitFactory,nPrio,"Default");
+ InitFactory();
+}
+void GraphicViewShellBase::InitFactory()
+{
+ SFX_VIEW_REGISTRATION(GraphicDocShell);
+}
+
+
+
+
+
+
+
+
+GraphicViewShellBase::GraphicViewShellBase (
+ SfxViewFrame* _pFrame,
+ SfxViewShell* pOldShell)
+ : ViewShellBase (_pFrame, pOldShell)
+{
+}
+
+
+
+
+GraphicViewShellBase::~GraphicViewShellBase (void)
+{
+}
+
+
+
+
+void GraphicViewShellBase::Execute (SfxRequest& rRequest)
+{
+ sal_uInt16 nSlotId = rRequest.GetSlot();
+
+ switch (nSlotId)
+ {
+ case SID_NOTES_WINDOW:
+ case SID_SLIDE_SORTER_MULTI_PANE_GUI:
+ case SID_DIAMODE:
+ case SID_OUTLINEMODE:
+ case SID_NOTESMODE:
+ case SID_HANDOUTMODE:
+ case SID_SHOW_TOOL_PANEL:
+ // Prevent some Impress-only slots from being executed.
+ rRequest.Cancel();
+ break;
+
+ case SID_TASKPANE:
+ case SID_SWITCH_SHELL:
+ case SID_LEFT_PANE_DRAW:
+ case SID_LEFT_PANE_IMPRESS:
+ default:
+ // The remaining requests are forwarded to our base class.
+ ViewShellBase::Execute (rRequest);
+ break;
+ }
+
+}
+
+
+
+
+void GraphicViewShellBase::InitializeFramework (void)
+{
+ com::sun::star::uno::Reference<com::sun::star::frame::XController>
+ xController (GetController());
+ sd::framework::DrawModule::Initialize(xController);
+}
+
+
+} // end of namespace sd
+
diff --git a/sd/source/ui/view/ImpressViewShellBase.cxx b/sd/source/ui/view/ImpressViewShellBase.cxx
new file mode 100755
index 000000000000..d4fb1316c948
--- /dev/null
+++ b/sd/source/ui/view/ImpressViewShellBase.cxx
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_sd.hxx"
+
+#include "ImpressViewShellBase.hxx"
+
+#include "DrawDocShell.hxx"
+#include "sdresid.hxx"
+#include "strings.hrc"
+#include "app.hrc"
+#include "framework/FrameworkHelper.hxx"
+#include "framework/ImpressModule.hxx"
+#include "MasterPageObserver.hxx"
+#include <sfx2/request.hxx>
+
+namespace sd {
+
+TYPEINIT1(ImpressViewShellBase, ViewShellBase);
+
+// We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
+// new ImpressViewShellBase object has been constructed.
+
+SfxViewFactory* ImpressViewShellBase::pFactory;
+SfxViewShell* __EXPORT ImpressViewShellBase::CreateInstance (
+ SfxViewFrame *pFrame, SfxViewShell *pOldView)
+{
+ ImpressViewShellBase* pBase = new ImpressViewShellBase(pFrame, pOldView);
+ pBase->LateInit(::rtl::OUString());
+ return pBase;
+}
+void ImpressViewShellBase::RegisterFactory( sal_uInt16 nPrio )
+{
+ pFactory = new SfxViewFactory(
+ &CreateInstance,&InitFactory,nPrio,"Default");
+ InitFactory();
+}
+void ImpressViewShellBase::InitFactory()
+{
+ SFX_VIEW_REGISTRATION(DrawDocShell);
+}
+
+
+
+
+
+
+
+
+ImpressViewShellBase::ImpressViewShellBase (
+ SfxViewFrame* _pFrame,
+ SfxViewShell* pOldShell)
+ : ViewShellBase (_pFrame, pOldShell)
+{
+ MasterPageObserver::Instance().RegisterDocument (*GetDocShell()->GetDoc());
+}
+
+
+
+
+ImpressViewShellBase::~ImpressViewShellBase (void)
+{
+ MasterPageObserver::Instance().UnregisterDocument (*GetDocShell()->GetDoc());
+}
+
+
+
+
+void ImpressViewShellBase::Execute (SfxRequest& rRequest)
+{
+ sal_uInt16 nSlotId = rRequest.GetSlot();
+
+ switch (nSlotId)
+ {
+ case SID_LEFT_PANE_DRAW:
+ // Prevent a Draw-only slots from being executed.
+ rRequest.Cancel();
+ break;
+
+ default:
+ // The remaining requests are forwarded to our base class.
+ ViewShellBase::Execute(rRequest);
+ break;
+ }
+}
+
+
+
+
+void ImpressViewShellBase::InitializeFramework (void)
+{
+ ::com::sun::star::uno::Reference<com::sun::star::frame::XController>
+ xController (GetController());
+ sd::framework::ImpressModule::Initialize(xController);
+}
+
+} // end of namespace sd
+
diff --git a/sd/source/ui/view/MediaObjectBar.cxx b/sd/source/ui/view/MediaObjectBar.cxx
new file mode 100755
index 000000000000..762a27acbc39
--- /dev/null
+++ b/sd/source/ui/view/MediaObjectBar.cxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * 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 "MediaObjectBar.hxx"
+#include <avmedia/mediaitem.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/request.hxx>
+#include <sfx2/objface.hxx>
+#include <svl/whiter.hxx>
+#include <svl/itempool.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
+
+#include "app.hrc"
+#include "res_bmp.hrc"
+#include "glob.hrc"
+#include "strings.hrc"
+#include "DrawDocShell.hxx"
+#include "ViewShell.hxx"
+#include "Window.hxx"
+#include "drawview.hxx"
+#include "sdresid.hxx"
+#include "drawdoc.hxx"
+
+using namespace sd;
+
+#define MediaObjectBar
+#include "sdslots.hxx"
+
+namespace sd {
+
+// ------------------
+// - MediaObjectBar -
+// ------------------
+
+TYPEINIT1( MediaObjectBar, SfxShell );
+
+// -----------------------------------------------------------------------------
+
+SFX_IMPL_INTERFACE( MediaObjectBar, SfxShell, SdResId( STR_MEDIAOBJECTBARSHELL ) )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+MediaObjectBar::MediaObjectBar( ViewShell* pSdViewShell, ::sd::View* pSdView ) :
+ SfxShell( pSdViewShell->GetViewShell() ),
+ mpView( pSdView ),
+ mpViewSh( pSdViewShell )
+{
+ DrawDocShell* pDocShell = mpViewSh->GetDocSh();
+
+ SetPool( &pDocShell->GetPool() );
+ SetUndoManager( pDocShell->GetUndoManager() );
+ SetRepeatTarget( mpView );
+ SetHelpId( SD_IF_SDDRAWMEDIAOBJECTBAR );
+ SetName( String( SdResId( RID_DRAW_MEDIA_TOOLBOX ) ) );
+}
+
+// -----------------------------------------------------------------------------
+
+MediaObjectBar::~MediaObjectBar()
+{
+ SetRepeatTarget( NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaObjectBar::GetState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ while( nWhich )
+ {
+ if( SID_AVMEDIA_TOOLBOX == nWhich )
+ {
+ SdrMarkList* pMarkList = new SdrMarkList( mpView->GetMarkedObjectList() );
+ bool bDisable = true;
+
+ if( 1 == pMarkList->GetMarkCount() )
+ {
+ SdrObject* pObj =pMarkList->GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrMediaObj ) )
+ {
+ ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX );
+
+ static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem );
+ rSet.Put( aItem );
+ bDisable = false;
+ }
+ }
+
+ if( bDisable )
+ rSet.DisableItem( SID_AVMEDIA_TOOLBOX );
+
+ delete pMarkList;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void MediaObjectBar::Execute( SfxRequest& rReq )
+{
+ if( SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, sal_False, &pItem ) ) )
+ pItem = NULL;
+
+ if( pItem )
+ {
+ SdrMarkList* pMarkList = new SdrMarkList( mpView->GetMarkedObjectList() );
+
+ if( 1 == pMarkList->GetMarkCount() )
+ {
+ SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj && pObj->ISA( SdrMediaObj ) )
+ {
+ static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
+ static_cast< const ::avmedia::MediaItem& >( *pItem ) );
+ }
+ }
+
+ delete pMarkList;
+ }
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/OutlineViewShellBase.cxx b/sd/source/ui/view/OutlineViewShellBase.cxx
new file mode 100755
index 000000000000..0f3b60afa998
--- /dev/null
+++ b/sd/source/ui/view/OutlineViewShellBase.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * 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 "OutlineViewShellBase.hxx"
+#include "sdresid.hxx"
+#include "DrawDocShell.hxx"
+#include "strings.hrc"
+#include "framework/FrameworkHelper.hxx"
+
+namespace sd {
+
+class DrawDocShell;
+
+TYPEINIT1(OutlineViewShellBase, ViewShellBase);
+
+// We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
+// new OutlineViewShellBase object has been constructed.
+
+SfxViewFactory* OutlineViewShellBase::pFactory;
+SfxViewShell* __EXPORT OutlineViewShellBase::CreateInstance (
+ SfxViewFrame *pFrame, SfxViewShell *pOldView)
+{
+ OutlineViewShellBase* pBase = new OutlineViewShellBase(pFrame, pOldView);
+ pBase->LateInit(framework::FrameworkHelper::msOutlineViewURL);
+ return pBase;
+}
+void OutlineViewShellBase::RegisterFactory( sal_uInt16 nPrio )
+{
+ pFactory = new SfxViewFactory(
+ &CreateInstance,&InitFactory,nPrio,"Outline");
+ InitFactory();
+}
+void OutlineViewShellBase::InitFactory()
+{
+ SFX_VIEW_REGISTRATION(DrawDocShell);
+}
+
+
+
+
+OutlineViewShellBase::OutlineViewShellBase (
+ SfxViewFrame* _pFrame,
+ SfxViewShell* pOldShell)
+ : ImpressViewShellBase (_pFrame, pOldShell)
+{
+}
+
+
+
+
+OutlineViewShellBase::~OutlineViewShellBase (void)
+{
+}
+
+
+
+
+} // end of namespace sd
+
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
new file mode 100755
index 000000000000..29440af545bc
--- /dev/null
+++ b/sd/source/ui/view/Outliner.cxx
@@ -0,0 +1,1828 @@
+/*************************************************************************
+ *
+ * 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 "Outliner.hxx"
+#include <vcl/wrkwin.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/editstat.hxx>
+#include <vcl/outdev.hxx>
+#include <svx/dlgutil.hxx>
+#include <svx/xtable.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/printer.hxx>
+#include <svx/svxerr.hxx>
+#include <svx/svdotext.hxx>
+#include <editeng/unolingu.hxx>
+#include <svx/svditer.hxx>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/processfactory.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/forbiddencharacterstable.hxx>
+#include <svx/srchdlg.hxx>
+#include <unotools/linguprops.hxx>
+#include <unotools/lingucfg.hxx>
+#include <editeng/editeng.hxx>
+#include <vcl/metric.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svtools/langtab.hxx>
+#include <tools/diagnose_ex.h>
+
+#include "strings.hrc"
+#include "sdstring.hrc"
+#include "eetext.hxx"
+#include "sdpage.hxx"
+#include "app.hxx"
+#include "Window.hxx"
+#include "sdresid.hxx"
+#include "DrawViewShell.hxx"
+#include "OutlineViewShell.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "FrameView.hxx"
+#include "optsitem.hxx"
+#include "drawview.hxx"
+#include "ViewShellBase.hxx"
+#include "SpellDialogChildWindow.hxx"
+#include "ToolBarManager.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include <svx/svxids.hrc>
+#include <editeng/editerr.hxx>
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::linguistic2;
+
+class SfxStyleSheetPool;
+
+namespace sd {
+
+class Outliner::Implementation
+{
+public:
+ /** The original edit mode directly after switching to a different view
+ mode. Used for restoring the edit mode when leaving that view mode
+ again.
+ */
+ EditMode meOriginalEditMode;
+
+ Implementation (void);
+ ~Implementation (void);
+
+ /** Return the OutlinerView that was provided by the last call to
+ ProvideOutlinerView() (or NULL when there was no such call.)
+ */
+ OutlinerView* GetOutlinerView (void);
+
+ /** Provide in the member mpOutlineView an instance of OutlinerView that
+ is either taken from the ViewShell, when it is an OutlineViewShell,
+ or is created. When an OutlinerView already exists it is initialied.
+ */
+ void ProvideOutlinerView (
+ Outliner& rOutliner,
+ const ::boost::shared_ptr<ViewShell>& rpViewShell,
+ ::Window* pWindow);
+
+ /** This method is called when the OutlinerView is no longer used.
+ */
+ void ReleaseOutlinerView (void);
+
+private:
+ /** Flag that specifies whether we own the outline view pointed to by
+ <member>mpOutlineView</member> and thus have to
+ delete it in <member>EndSpelling()</member>.
+ */
+ bool mbOwnOutlineView;
+
+ /** The outline view used for searching and spelling. If searching or
+ spell checking an outline view this data member points to that view.
+ For all other views an instance is created. The
+ <member>mbOwnOutlineView</member> distinguishes between both cases.
+ */
+ OutlinerView* mpOutlineView;
+};
+
+
+
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+Outliner::Outliner( SdDrawDocument* pDoc, sal_uInt16 nMode )
+ : SdrOutliner( &pDoc->GetItemPool(), nMode ),
+ mpImpl(new Implementation()),
+ meMode(SEARCH),
+ mpView(NULL),
+ mpViewShell(),
+ mpWindow(NULL),
+ mpDrawDocument(pDoc),
+ mnConversionLanguage(LANGUAGE_NONE),
+ mnIgnoreCurrentPageChangesLevel(0),
+ mbStringFound(sal_False),
+ mbMatchMayExist(false),
+ mnPageCount(0),
+ mnObjectCount(0),
+ mbEndOfSearch(sal_False),
+ mbFoundObject(sal_False),
+ mbError(sal_False),
+ mbDirectionIsForward(true),
+ mbRestrictSearchToSelection(false),
+ maMarkListCopy(),
+ mbProcessCurrentViewOnly(false),
+ mpObj(NULL),
+ mpFirstObj(NULL),
+ mpTextObj(NULL),
+ mnText(0),
+ mpParaObj(NULL),
+ meStartViewMode(PK_STANDARD),
+ meStartEditMode(EM_PAGE),
+ mnStartPageIndex((sal_uInt16)-1),
+ mpStartEditedObject(NULL),
+ maStartSelection(),
+ mpSearchItem(NULL),
+ maObjectIterator(),
+ maCurrentPosition(),
+ maSearchStartPosition(),
+ maLastValidPosition(),
+ mbSelectionHasChanged(false),
+ mbExpectingSelectionChangeEvent(false),
+ mbWholeDocumentProcessed(false),
+ mbPrepareSpellingPending(true),
+ mbViewShellValid(true)
+{
+ SetStyleSheetPool((SfxStyleSheetPool*) mpDrawDocument->GetStyleSheetPool());
+ SetEditTextObjectPool( &pDoc->GetItemPool() );
+ SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
+ SetForbiddenCharsTable( pDoc->GetForbiddenCharsTable() );
+
+ sal_uLong nCntrl = GetControlWord();
+ nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
+ nCntrl |= EE_CNTRL_URLSFXEXECUTE;
+ nCntrl |= EE_CNTRL_MARKFIELDS;
+ nCntrl |= EE_CNTRL_AUTOCORRECT;
+
+ sal_Bool bOnlineSpell = false;
+
+ DrawDocShell* pDocSh = mpDrawDocument->GetDocSh();
+
+ if (pDocSh)
+ {
+ bOnlineSpell = mpDrawDocument->GetOnlineSpell();
+ }
+ else
+ {
+ bOnlineSpell = false;
+
+ try
+ {
+ const SvtLinguConfig aLinguConfig;
+ Any aAny;
+
+ aAny = aLinguConfig.GetProperty(
+ rtl::OUString::createFromAscii( UPN_IS_SPELL_AUTO ) );
+ aAny >>= bOnlineSpell;
+ }
+ catch( ... )
+ {
+ DBG_ERROR( "Ill. type in linguistic property" );
+ }
+ }
+
+ if (bOnlineSpell)
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+
+ SetControlWord(nCntrl);
+
+ Reference< XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
+ if ( xSpellChecker.is() )
+ SetSpeller( xSpellChecker );
+
+ Reference< XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
+ if( xHyphenator.is() )
+ SetHyphenator( xHyphenator );
+
+ SetDefaultLanguage( Application::GetSettings().GetLanguage() );
+}
+
+
+
+
+/// Nothing spectecular in the destructor.
+Outliner::~Outliner (void)
+{
+ mpImpl.reset();
+}
+
+
+
+
+/** Prepare find&replace or spellchecking. This distinguishes between three
+ cases:
+ <ol>
+ <li>The current shell is a <type>DrawViewShell</type>: Create a
+ <type>OutlinerView</type> object and search all objects of (i) the
+ current mark list, (ii) of the current view, or (iii) of all the view
+ combinations:
+ <ol>
+ <li>Draw view, slide view</li>
+ <li>Draw view, background view</li>
+ <li>Notes view, slide view</li>
+ <li>Notes view, background view</li>
+ <li>Handout view, slide view</li>
+ <li>Handout view, background view</li>
+ </ol>
+
+ <li>When the current shell is a <type>SdOutlineViewShell</type> then
+ directly operate on it. No switching into other views takes place.</li>
+
+ <li>For a <type>SlideViewShell</type> no action is performed.</li>
+ </ol>
+*/
+void Outliner::PrepareSpelling (void)
+{
+ if (mbViewShellValid)
+ {
+ mbPrepareSpellingPending = false;
+
+ ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current());
+ if (pBase != NULL)
+ SetViewShell (pBase->GetMainViewShell());
+ SetRefDevice( SD_MOD()->GetRefDevice( *mpDrawDocument->GetDocSh() ) );
+
+ if (mpViewShell.get() != NULL)
+ {
+ mbStringFound = sal_False;
+
+ mbWholeDocumentProcessed = false;
+ // Supposed that we are not located at the very beginning/end of
+ // the document then there may be a match in the document
+ // prior/after the current position.
+ mbMatchMayExist = sal_True;
+
+ maObjectIterator = ::sd::outliner::Iterator();
+ maSearchStartPosition = ::sd::outliner::Iterator();
+ RememberStartPosition();
+
+ mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow);
+
+ HandleChangedSelection ();
+ }
+ ClearModifyFlag();
+ }
+}
+
+
+
+
+
+void Outliner::StartSpelling (void)
+{
+ meMode = SPELL;
+ mbDirectionIsForward = true;
+ mpSearchItem = NULL;
+}
+
+/** Proxy for method from base class to avoid compiler warning */
+void Outliner::StartSpelling(EditView& rView, unsigned char c)
+{
+ SdrOutliner::StartSpelling( rView, c );
+}
+
+/** Free all resources acquired during the search/spell check. After a
+ spell check the start position is restored here.
+*/
+void Outliner::EndSpelling (void)
+{
+ if (mbViewShellValid)
+ {
+ // Keep old view shell alive until we release the outliner view.
+ ::boost::shared_ptr<ViewShell> pOldViewShell (mpViewShell);
+
+ ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current());
+ if (pBase != NULL)
+ mpViewShell = pBase->GetMainViewShell();
+ else
+ mpViewShell.reset();
+
+ // When in <member>PrepareSpelling()</member> a new outline view has
+ // been created then delete it here.
+ sal_Bool bViewIsDrawViewShell(mpViewShell.get()!=NULL
+ && mpViewShell->ISA(DrawViewShell));
+ if (bViewIsDrawViewShell)
+ {
+ SetStatusEventHdl(Link());
+ mpView = mpViewShell->GetView();
+ mpView->UnmarkAllObj (mpView->GetSdrPageView());
+ mpView->SdrEndTextEdit();
+ // Make FuSelection the current function.
+ mpViewShell->GetDispatcher()->Execute(
+ SID_OBJECT_SELECT,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
+
+ // Remove and, if previously created by us, delete the outline
+ // view.
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ {
+ RemoveView(pOutlinerView);
+ mpImpl->ReleaseOutlinerView();
+ }
+
+ SetUpdateMode(sal_True);
+ }
+
+ // #95811# Before clearing the modify flag use it as a hint that
+ // changes were done at SpellCheck
+ if(IsModified())
+ {
+ if(mpView && mpView->ISA(OutlineView))
+ static_cast<OutlineView*>(mpView)->PrepareClose(sal_False);
+ if(mpDrawDocument && !mpDrawDocument->IsChanged())
+ mpDrawDocument->SetChanged(sal_True);
+ }
+
+ // #95811# now clear the modify flag to have a specified state of
+ // Outliner
+ ClearModifyFlag();
+
+ // When spell checking then restore the start position.
+ if (meMode==SPELL || meMode==TEXT_CONVERSION)
+ RestoreStartPosition ();
+ }
+
+ mpViewShell.reset();
+ mpView = NULL;
+ mpWindow = NULL;
+}
+
+
+
+
+sal_Bool Outliner::SpellNextDocument (void)
+{
+ if (mpViewShell->ISA(OutlineViewShell))
+ {
+ // When doing a spell check in the outline view then there is
+ // only one document.
+ mbEndOfSearch = true;
+ EndOfSearch ();
+ }
+ else
+ {
+ if (mpView->ISA(OutlineView))
+ ((OutlineView*)mpView)->PrepareClose(sal_False);
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True );
+
+ Initialize (true);
+
+ mpWindow = mpViewShell->GetActiveWindow();
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ pOutlinerView->SetWindow(mpWindow);
+ ProvideNextTextObject ();
+
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False );
+ ClearModifyFlag();
+ }
+
+ return mbEndOfSearch ? sal_False : sal_True;
+
+}
+
+
+/*************************************************************************
+|*
+|* Spelling: naechstes TextObjekt pruefen
+|*
+\************************************************************************/
+
+::svx::SpellPortions Outliner::GetNextSpellSentence (void)
+{
+ ::svx::SpellPortions aResult;
+
+ DetectChange();
+ // Iterate over sentences and text shapes until a sentence with a
+ // spelling error has been found. If no such sentence can be
+ // found the loop is left through a break.
+ // It is the responsibility of the sd outliner object to correctly
+ // iterate over all text shapes, i.e. switch between views, wrap
+ // arround at the end of the document, stop when all text shapes
+ // have been examined exactly once.
+ bool bFoundNextSentence = false;
+ while ( ! bFoundNextSentence)
+ {
+ OutlinerView* pOutlinerView = GetView(0);
+ if (pOutlinerView != NULL)
+ {
+ ESelection aCurrentSelection (pOutlinerView->GetSelection());
+ if ( ! mbMatchMayExist
+ && maStartSelection.IsLess(aCurrentSelection))
+ EndOfSearch();
+
+ // Advance to the next sentence.
+ bFoundNextSentence = SpellSentence (
+ pOutlinerView->GetEditView(),
+ aResult, false);
+ }
+
+ // When no sentence with spelling errors has been found in the
+ // currently selected text shape or there is no selected text
+ // shape then advance to the next text shape.
+ if ( ! bFoundNextSentence)
+ if ( ! SpellNextDocument())
+ // All text objects have been processed so exit the
+ // loop and return an empty portions list.
+ break;
+ }
+
+ return aResult;
+}
+
+
+
+
+/** Go to next match.
+*/
+bool Outliner::StartSearchAndReplace (const SvxSearchItem* pSearchItem)
+{
+ sal_Bool bEndOfSearch = sal_True;
+
+ if (mbViewShellValid)
+ {
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True );
+ if (mbPrepareSpellingPending)
+ PrepareSpelling();
+ ViewShellBase* pBase = PTR_CAST(ViewShellBase,SfxViewShell::Current());
+ // Determine whether we have to abort the search. This is necessary
+ // when the main view shell does not support searching.
+ bool bAbort = false;
+ if (pBase != NULL)
+ {
+ ::boost::shared_ptr<ViewShell> pShell (pBase->GetMainViewShell());
+ SetViewShell(pShell);
+ if (pShell.get() == NULL)
+ bAbort = true;
+ else
+ switch (pShell->GetShellType())
+ {
+ case ViewShell::ST_DRAW:
+ case ViewShell::ST_IMPRESS:
+ case ViewShell::ST_NOTES:
+ case ViewShell::ST_HANDOUT:
+ case ViewShell::ST_OUTLINE:
+ bAbort = false;
+ break;
+ default:
+ bAbort = true;
+ break;
+ }
+ }
+
+ if ( ! bAbort)
+ {
+ meMode = SEARCH;
+ mpSearchItem = pSearchItem;
+
+ mbFoundObject = sal_False;
+
+ Initialize ( ! mpSearchItem->GetBackward());
+
+ sal_uInt16 nCommand = mpSearchItem->GetCommand();
+ if (nCommand == SVX_SEARCHCMD_REPLACE_ALL)
+ bEndOfSearch = SearchAndReplaceAll ();
+ else
+ {
+ RememberStartPosition ();
+ bEndOfSearch = SearchAndReplaceOnce ();
+ //#107233# restore start position if nothing was found
+ if(!mbStringFound)
+ RestoreStartPosition ();
+ else
+ mnStartPageIndex = (sal_uInt16)-1;
+ }
+ }
+ else
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False );
+ }
+
+ return bEndOfSearch;
+}
+
+
+
+
+void Outliner::Initialize (bool bDirectionIsForward)
+{
+ const bool bIsAtEnd (maObjectIterator == ::sd::outliner::OutlinerContainer(this).end());
+ const bool bOldDirectionIsForward = mbDirectionIsForward;
+ mbDirectionIsForward = bDirectionIsForward;
+
+ if (maObjectIterator == ::sd::outliner::Iterator())
+ {
+ // Initialize a new search.
+ maObjectIterator = ::sd::outliner::OutlinerContainer(this).current();
+ maCurrentPosition = *maObjectIterator;
+
+ // In case we are searching in an outline view then first remove the
+ // current selection and place cursor at its start or end.
+ if (mpViewShell->ISA(OutlineViewShell))
+ {
+ ESelection aSelection = mpImpl->GetOutlinerView()->GetSelection ();
+ if (mbDirectionIsForward)
+ {
+ aSelection.nEndPara = aSelection.nStartPara;
+ aSelection.nEndPos = aSelection.nStartPos;
+ }
+ else
+ {
+ aSelection.nStartPara = aSelection.nEndPara;
+ aSelection.nStartPos = aSelection.nEndPos;
+ }
+ mpImpl->GetOutlinerView()->SetSelection (aSelection);
+ }
+
+ // When not beginning the search at the beginning of the search area
+ // then there may be matches before the current position.
+ mbMatchMayExist = (maObjectIterator!=::sd::outliner::OutlinerContainer(this).begin());
+ }
+ else if (bOldDirectionIsForward != mbDirectionIsForward)
+ {
+ // Requested iteration direction has changed. Turn arround the iterator.
+ maObjectIterator.Reverse();
+ if (bIsAtEnd)
+ {
+ // The iterator has pointed to end(), which after the search
+ // direction is reversed, becomes begin().
+ maObjectIterator = ::sd::outliner::OutlinerContainer(this).begin();
+ }
+ else
+ {
+ // The iterator has pointed to the object one ahead/before the current
+ // one. Now move it to the one before/ahead the current one.
+ ++maObjectIterator;
+ ++maObjectIterator;
+ }
+
+ mbMatchMayExist = true;
+ }
+
+ // Initialize the last valid position with where the search starts so
+ // that it always points to a valid position.
+ maLastValidPosition = *::sd::outliner::OutlinerContainer(this).current();
+}
+
+
+
+
+bool Outliner::SearchAndReplaceAll (void)
+{
+ // Save the current position to be restored after having replaced all
+ // matches.
+ RememberStartPosition ();
+
+ if (mpViewShell->ISA(OutlineViewShell))
+ {
+ // Put the cursor to the beginning/end of the outliner.
+ mpImpl->GetOutlinerView()->SetSelection (GetSearchStartPosition ());
+
+ // The outliner does all the work for us when we are in this mode.
+ SearchAndReplaceOnce();
+ }
+ else if (mpViewShell->ISA(DrawViewShell))
+ {
+ // Go to beginning/end of document.
+ maObjectIterator = ::sd::outliner::OutlinerContainer(this).begin();
+ // Switch to the current object only if it is a valid text object.
+ ::sd::outliner::IteratorPosition aNewPosition (*maObjectIterator);
+ if (IsValidTextObject (aNewPosition))
+ {
+ maCurrentPosition = aNewPosition;
+ SetObject (maCurrentPosition);
+ }
+
+ // Search/replace until the end of the document is reached.
+ bool bFoundMatch;
+ do
+ {
+ bFoundMatch = ! SearchAndReplaceOnce();
+ }
+ while (bFoundMatch);
+ }
+
+ RestoreStartPosition ();
+
+ return true;
+}
+
+
+
+
+bool Outliner::SearchAndReplaceOnce (void)
+{
+ DetectChange ();
+
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ DBG_ASSERT(pOutlinerView!=NULL && GetEditEngine().HasView( &pOutlinerView->GetEditView() ),
+ "SearchAndReplace without valid view!" );
+
+ if( NULL == pOutlinerView || !GetEditEngine().HasView( &pOutlinerView->GetEditView() ) )
+ return true;
+
+ if (mpViewShell != NULL)
+ {
+ mpView = mpViewShell->GetView();
+ mpWindow = mpViewShell->GetActiveWindow();
+ pOutlinerView->SetWindow(mpWindow);
+
+ if (mpViewShell->ISA(DrawViewShell) )
+ {
+ // When replacing we first check if there is a selection
+ // indicating a match. If there is then replace it. The
+ // following call to StartSearchAndReplace will then search for
+ // the next match.
+ if (meMode == SEARCH
+ && mpSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE)
+ if (pOutlinerView->GetSelection().HasRange())
+ pOutlinerView->StartSearchAndReplace(*mpSearchItem);
+
+ // Search for the next match.
+ sal_uLong nMatchCount = 0;
+ if (mpSearchItem->GetCommand() != SVX_SEARCHCMD_REPLACE_ALL)
+ nMatchCount = pOutlinerView->StartSearchAndReplace(*mpSearchItem);
+
+ // Go to the next text object when there have been no matches in
+ // the current object or the whole object has already been
+ // processed.
+ if (nMatchCount==0 || mpSearchItem->GetCommand()==SVX_SEARCHCMD_REPLACE_ALL)
+ {
+ ProvideNextTextObject ();
+
+ if ( ! mbEndOfSearch)
+ {
+ // Remember the current position as the last one with a
+ // text object.
+ maLastValidPosition = maCurrentPosition;
+
+ // Now that the mbEndOfSearch flag guards this block the
+ // following assertion and return should not be
+ // necessary anymore.
+ DBG_ASSERT(GetEditEngine().HasView(&pOutlinerView->GetEditView() ),
+ "SearchAndReplace without valid view!" );
+ if ( ! GetEditEngine().HasView( &pOutlinerView->GetEditView() ) )
+ {
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False );
+ return true;
+ }
+
+ if (meMode == SEARCH)
+ nMatchCount = pOutlinerView->StartSearchAndReplace(*mpSearchItem);
+ }
+ }
+ }
+ else if (mpViewShell->ISA(OutlineViewShell))
+ {
+ mpDrawDocument->GetDocSh()->SetWaitCursor (sal_False);
+ // The following loop is executed more then once only when a
+ // wrap arround search is done.
+ while (true)
+ {
+ int nResult = pOutlinerView->StartSearchAndReplace(*mpSearchItem);
+ if (nResult == 0)
+ {
+ if (HandleFailedSearch ())
+ {
+ pOutlinerView->SetSelection (GetSearchStartPosition ());
+ continue;
+ }
+ }
+ else
+ mbStringFound = true;
+ break;
+ }
+ }
+ }
+
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False );
+
+ return mbEndOfSearch;
+}
+
+
+
+
+/** Try to detect whether the document or the view (shell) has changed since
+ the last time <member>StartSearchAndReplace()</member> has been called.
+*/
+void Outliner::DetectChange (void)
+{
+ ::sd::outliner::IteratorPosition aPosition (maCurrentPosition);
+
+ ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
+ ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell));
+
+ // Detect whether the view has been switched from the outside.
+ if (pDrawViewShell.get() != NULL
+ && (aPosition.meEditMode != pDrawViewShell->GetEditMode()
+ || aPosition.mePageKind != pDrawViewShell->GetPageKind()))
+ {
+ // Either the edit mode or the page kind has changed.
+ SetStatusEventHdl(Link());
+
+ SdrPageView* pPageView = mpView->GetSdrPageView();
+ if (pPageView != NULL)
+ mpView->UnmarkAllObj (pPageView);
+ mpView->SdrEndTextEdit();
+ SetUpdateMode(sal_False);
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ pOutlinerView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
+ if (meMode == SPELL)
+ SetPaperSize( Size(1, 1) );
+ SetText( String(), GetParagraph( 0 ) );
+
+ RememberStartPosition ();
+
+ mnPageCount = mpDrawDocument->GetSdPageCount(pDrawViewShell->GetPageKind());
+ maObjectIterator = ::sd::outliner::OutlinerContainer(this).current();
+ }
+
+ // Detect change of the set of selected objects. If their number has
+ // changed start again with the first selected object.
+ else if (DetectSelectionChange())
+ {
+ HandleChangedSelection ();
+ maObjectIterator = ::sd::outliner::OutlinerContainer(this).current();
+ }
+
+ // Detect change of page count. Restart search at first/last page in
+ // that case.
+ else if (aPosition.meEditMode == EM_PAGE
+ && mpDrawDocument->GetSdPageCount(aPosition.mePageKind) != mnPageCount)
+ {
+ // The number of pages has changed.
+ mnPageCount = mpDrawDocument->GetSdPageCount(aPosition.mePageKind);
+ maObjectIterator = ::sd::outliner::OutlinerContainer(this).current();
+ }
+ else if (aPosition.meEditMode == EM_MASTERPAGE
+ && mpDrawDocument->GetSdPageCount(aPosition.mePageKind) != mnPageCount)
+ {
+ // The number of master pages has changed.
+ mnPageCount = mpDrawDocument->GetSdPageCount(aPosition.mePageKind);
+ maObjectIterator = ::sd::outliner::OutlinerContainer(this).current();
+ }
+}
+
+
+
+
+bool Outliner::DetectSelectionChange (void)
+{
+ bool bSelectionHasChanged = false;
+ sal_uLong nMarkCount = mpView->GetMarkedObjectList().GetMarkCount();
+
+ // If mpObj is NULL then we have not yet found our first match.
+ // Detecting a change makes no sense.
+ if (mpObj != NULL)
+ switch (nMarkCount)
+ {
+ case 0:
+ // The selection has changed when previously there have been
+ // selected objects.
+ bSelectionHasChanged = mbRestrictSearchToSelection;
+ break;
+ case 1:
+ // Check if the only selected object is not the one that we
+ // had selected.
+ if (mpView != NULL)
+ {
+ SdrMark* pMark = mpView->GetMarkedObjectList().GetMark(0);
+ if (pMark != NULL)
+ bSelectionHasChanged = (mpObj != pMark->GetMarkedSdrObj ());
+ }
+ break;
+ default:
+ // We had selected exactly one object.
+ bSelectionHasChanged = true;
+ break;
+ }
+
+ return bSelectionHasChanged;
+}
+
+
+
+
+void Outliner::RememberStartPosition (void)
+{
+ if (mpViewShell->ISA(DrawViewShell))
+ {
+ ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
+ ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell));
+ if (pDrawViewShell.get() != NULL)
+ {
+ meStartViewMode = pDrawViewShell->GetPageKind();
+ meStartEditMode = pDrawViewShell->GetEditMode();
+ mnStartPageIndex = pDrawViewShell->GetCurPageId() - 1;
+ }
+
+ if (mpView != NULL)
+ {
+ mpStartEditedObject = mpView->GetTextEditObject();
+ if (mpStartEditedObject != NULL)
+ {
+ // Try to retrieve current caret position only when there is an
+ // edited object.
+ ::Outliner* pOutliner =
+ static_cast<DrawView*>(mpView)->GetTextEditOutliner();
+ if (pOutliner!=NULL && pOutliner->GetViewCount()>0)
+ {
+ OutlinerView* pOutlinerView = pOutliner->GetView(0);
+ maStartSelection = pOutlinerView->GetSelection();
+ }
+ }
+ }
+ }
+ else if (mpViewShell->ISA(OutlineViewShell))
+ {
+ // Remember the current cursor position.
+ OutlinerView* pView = GetView(0);
+ if (pView != NULL)
+ pView->GetSelection();
+ }
+ else
+ {
+ mnStartPageIndex = (sal_uInt16)-1;
+ }
+}
+
+
+
+
+void Outliner::RestoreStartPosition (void)
+{
+ bool bRestore = true;
+ // Take a negative start page index as inidicator that restoring the
+ // start position is not requested.
+ if (mnStartPageIndex == (sal_uInt16)-1 )
+ bRestore = false;
+ // Dont't resore when the view shell is not valid.
+ if (mpViewShell == NULL)
+ bRestore = false;
+ if ( ! mbViewShellValid)
+ bRestore = false;
+
+ if (bRestore)
+ {
+ if (mpViewShell->ISA(DrawViewShell))
+ {
+ ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
+ ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell));
+ SetViewMode (meStartViewMode);
+ if (pDrawViewShell.get() != NULL)
+ SetPage (meStartEditMode, mnStartPageIndex);
+
+
+ if (mpStartEditedObject != NULL)
+ {
+ // Turn on the text toolbar as it is done in FuText so that
+ // undo manager setting/restoring in
+ // sd::View::{Beg,End}TextEdit() works on the same view shell.
+ mpViewShell->GetViewShellBase().GetToolBarManager()->SetToolBarShell(
+ ToolBarManager::TBG_FUNCTION,
+ RID_DRAW_TEXT_TOOLBOX);
+
+ mpView->SdrBeginTextEdit(mpStartEditedObject);
+ ::Outliner* pOutliner =
+ static_cast<DrawView*>(mpView)->GetTextEditOutliner();
+ if (pOutliner!=NULL && pOutliner->GetViewCount()>0)
+ {
+ OutlinerView* pOutlinerView = pOutliner->GetView(0);
+ pOutlinerView->SetSelection(maStartSelection);
+ }
+ }
+ }
+ else if (mpViewShell->ISA(OutlineViewShell))
+ {
+ // Set cursor to its old position.
+ OutlinerView* pView = GetView(0);
+ if (pView != NULL)
+ pView->SetSelection (maStartSelection);
+ }
+ }
+}
+
+
+
+
+/** The main purpose of this method is to iterate over all shape objects of
+ the search area (current selection, current view, or whole document)
+ until a text object has been found that contains at least one match or
+ until no such object can be found anymore. These two conditions are
+ expressed by setting one of the flags <member>mbFoundObject</member> or
+ <member>mbEndOfSearch</member> to <TRUE/>.
+*/
+void Outliner::ProvideNextTextObject (void)
+{
+ mbEndOfSearch = false;
+ mbFoundObject = false;
+
+ mpView->UnmarkAllObj (mpView->GetSdrPageView());
+ try
+ {
+ mpView->SdrEndTextEdit();
+ }
+ catch (::com::sun::star::uno::Exception e)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ SetUpdateMode(sal_False);
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ pOutlinerView->SetOutputArea( Rectangle( Point(), Size(1, 1) ) );
+ if (meMode == SPELL)
+ SetPaperSize( Size(1, 1) );
+ SetText( String(), GetParagraph( 0 ) );
+
+ mpTextObj = NULL;
+
+ // Iterate until a valid text object has been found or the search ends.
+ do
+ {
+ mpObj = NULL;
+ mpParaObj = NULL;
+
+ if (maObjectIterator != ::sd::outliner::OutlinerContainer(this).end())
+ {
+ maCurrentPosition = *maObjectIterator;
+ // Switch to the current object only if it is a valid text object.
+ if (IsValidTextObject (maCurrentPosition))
+ {
+ mpObj = SetObject (maCurrentPosition);
+ }
+ ++maObjectIterator;
+
+ if (mpObj != NULL)
+ {
+ PutTextIntoOutliner ();
+
+ if (mpViewShell != NULL)
+ switch (meMode)
+ {
+ case SEARCH:
+ PrepareSearchAndReplace ();
+ break;
+ case SPELL:
+ PrepareSpellCheck ();
+ break;
+ case TEXT_CONVERSION:
+ PrepareConversion();
+ break;
+ }
+ }
+ }
+ else
+ {
+ mbEndOfSearch = true;
+ EndOfSearch ();
+ }
+ }
+ while ( ! (mbFoundObject || mbEndOfSearch));
+}
+
+
+
+
+void Outliner::EndOfSearch (void)
+{
+ // Before we display a dialog we first jump to where the last valid text
+ // object was found. All page and view mode switching since then was
+ // temporary and should not be visible to the user.
+ if ( ! mpViewShell->ISA(OutlineViewShell))
+ SetObject (maLastValidPosition);
+
+ if (mbRestrictSearchToSelection)
+ ShowEndOfSearchDialog ();
+ else
+ {
+ // When no match has been found so far then terminate the search.
+ if ( ! mbMatchMayExist)
+ {
+ ShowEndOfSearchDialog ();
+ mbEndOfSearch = sal_True;
+ }
+ // Ask the user whether to wrap arround and continue the search or
+ // to terminate.
+ else if (meMode==TEXT_CONVERSION || ShowWrapArroundDialog ())
+ {
+ mbMatchMayExist = false;
+ // Everything back to beginning (or end?) of the document.
+ maObjectIterator = ::sd::outliner::OutlinerContainer(this).begin();
+ if (mpViewShell->ISA(OutlineViewShell))
+ {
+ // Set cursor to first character of the document.
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ pOutlinerView->SetSelection (GetSearchStartPosition ());
+ }
+
+ mbEndOfSearch = false;
+ }
+ else
+ {
+ // No wrap arround.
+ mbEndOfSearch = true;
+ }
+ }
+}
+
+void Outliner::ShowEndOfSearchDialog (void)
+{
+ String aString;
+ if (meMode == SEARCH)
+ {
+ if (mbStringFound)
+ aString = String( SdResId(STR_END_SEARCHING) );
+ else
+ aString = String( SdResId(STR_STRING_NOTFOUND) );
+ }
+ else
+ {
+ if (mpView->AreObjectsMarked())
+ aString = String(SdResId(STR_END_SPELLING_OBJ));
+ else
+ aString = String(SdResId(STR_END_SPELLING));
+ }
+
+ // Show the message in an info box that is modal with respect to the
+ // whole application.
+ InfoBox aInfoBox (NULL, aString);
+ ShowModalMessageBox (aInfoBox);
+
+ mbWholeDocumentProcessed = true;
+}
+
+
+
+
+bool Outliner::ShowWrapArroundDialog (void)
+{
+ bool bDoWrapArround = false;
+
+ // Determine whether to show the dialog.
+ bool bShowDialog = false;
+ if (mpSearchItem != NULL)
+ {
+ // When searching display the dialog only for single find&replace.
+ sal_uInt16 nCommand = mpSearchItem->GetCommand();
+ bShowDialog = (nCommand==SVX_SEARCHCMD_REPLACE)
+ || (nCommand==SVX_SEARCHCMD_FIND);
+ }
+ else
+ // Spell checking needs the dialog, too.
+ bShowDialog = (meMode == SPELL);
+
+ if (bShowDialog)
+ {
+ // The question text depends on the search direction.
+ sal_Bool bImpress = mpDrawDocument!=NULL
+ && mpDrawDocument->GetDocumentType() == DOCUMENT_TYPE_IMPRESS;
+ sal_uInt16 nStringId;
+ if (mbDirectionIsForward)
+ nStringId = bImpress
+ ? STR_SAR_WRAP_FORWARD
+ : STR_SAR_WRAP_FORWARD_DRAW;
+ else
+ nStringId = bImpress
+ ? STR_SAR_WRAP_BACKWARD
+ : STR_SAR_WRAP_BACKWARD_DRAW;
+
+ // Pop up question box that asks the user whether to wrap arround.
+ // The dialog is made modal with respect to the whole application.
+ QueryBox aQuestionBox (
+ NULL,
+ WB_YES_NO | WB_DEF_YES,
+ String(SdResId(nStringId)));
+ aQuestionBox.SetImage (QueryBox::GetStandardImage());
+ sal_uInt16 nBoxResult = ShowModalMessageBox(aQuestionBox);
+ bDoWrapArround = (nBoxResult == BUTTONID_YES);
+ }
+
+ return bDoWrapArround;
+}
+
+
+
+
+bool Outliner::IsValidTextObject (const ::sd::outliner::IteratorPosition& rPosition)
+{
+ SdrTextObj* pObject = dynamic_cast< SdrTextObj* >( rPosition.mxObject.get() );
+ return (pObject != NULL) && pObject->HasText() && ! pObject->IsEmptyPresObj();
+}
+
+
+
+
+void Outliner::PutTextIntoOutliner()
+{
+ mpTextObj = dynamic_cast<SdrTextObj*>( mpObj );
+ if ( mpTextObj && mpTextObj->HasText() && !mpTextObj->IsEmptyPresObj() )
+ {
+ SdrText* pText = mpTextObj->getText( mnText );
+ mpParaObj = pText ? pText->GetOutlinerParaObject() : NULL;
+
+ if (mpParaObj != NULL)
+ {
+ SetText(*mpParaObj);
+
+ ClearModifyFlag();
+ }
+ }
+ else
+ {
+ mpTextObj = NULL;
+ }
+}
+
+
+
+
+void Outliner::PrepareSpellCheck (void)
+{
+ EESpellState eState = HasSpellErrors();
+ DBG_ASSERT(eState != EE_SPELL_NOSPELLER, "No SpellChecker");
+
+ if (eState == EE_SPELL_NOLANGUAGE)
+ {
+ mbError = sal_True;
+ mbEndOfSearch = sal_True;
+ ErrorBox aErrorBox (NULL,
+ WB_OK,
+ String(SdResId(STR_NOLANGUAGE)));
+ ShowModalMessageBox (aErrorBox);
+ }
+ else if (eState != EE_SPELL_OK)
+ {
+ // When spell checking we have to test whether we have processed the
+ // whole document and have reached the start page again.
+ if (meMode == SPELL)
+ {
+ if (maSearchStartPosition == ::sd::outliner::Iterator())
+ // Remember the position of the first text object so that we
+ // know when we have processed the whole document.
+ maSearchStartPosition = maObjectIterator;
+ else if (maSearchStartPosition == maObjectIterator)
+ {
+ mbEndOfSearch = true;
+ }
+ }
+
+ EnterEditMode( sal_False );
+ }
+}
+
+
+
+
+void Outliner::PrepareSearchAndReplace (void)
+{
+ if (HasText( *mpSearchItem ))
+ {
+ mbStringFound = true;
+ mbMatchMayExist = true;
+
+ EnterEditMode ();
+
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False );
+ // Start seach at the right end of the current object's text
+ // depending on the search direction.
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ pOutlinerView->SetSelection (GetSearchStartPosition ());
+ }
+}
+
+
+
+
+void Outliner::SetViewMode (PageKind ePageKind)
+{
+ ::boost::shared_ptr<DrawViewShell> pDrawViewShell(
+ ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell));
+ if (pDrawViewShell.get()!=NULL && ePageKind != pDrawViewShell->GetPageKind())
+ {
+ // Restore old edit mode.
+ pDrawViewShell->ChangeEditMode(mpImpl->meOriginalEditMode, sal_False);
+
+ SetStatusEventHdl(Link());
+ ::rtl::OUString sViewURL;
+ switch (ePageKind)
+ {
+ case PK_STANDARD:
+ default:
+ sViewURL = framework::FrameworkHelper::msImpressViewURL;
+ break;
+ case PK_NOTES:
+ sViewURL = framework::FrameworkHelper::msNotesViewURL;
+ break;
+ case PK_HANDOUT:
+ sViewURL = framework::FrameworkHelper::msHandoutViewURL;
+ break;
+ }
+ // The text object iterator is destroyed when the shells are
+ // switched but we need it so save it and restore it afterwards.
+ ::sd::outliner::Iterator aIterator (maObjectIterator);
+ bool bMatchMayExist = mbMatchMayExist;
+
+ ViewShellBase& rBase = mpViewShell->GetViewShellBase();
+ SetViewShell(::boost::shared_ptr<ViewShell>());
+ framework::FrameworkHelper::Instance(rBase)->RequestView(
+ sViewURL,
+ framework::FrameworkHelper::msCenterPaneURL);
+
+ // Force (well, request) a synchronous update of the configuration.
+ // In a better world we would handle the asynchronous view update
+ // instead. But that would involve major restucturing of the
+ // Outliner code.
+ framework::FrameworkHelper::Instance(rBase)->RequestSynchronousUpdate();
+ SetViewShell(rBase.GetMainViewShell());
+
+ // Switching to another view shell has intermediatly called
+ // EndSpelling(). A PrepareSpelling() is pending, so call that now.
+ PrepareSpelling();
+
+ // Update the number of pages so that
+ // <member>DetectChange()</member> has the correct value to compare
+ // to.
+ mnPageCount = mpDrawDocument->GetSdPageCount(ePageKind);
+
+ maObjectIterator = aIterator;
+ mbMatchMayExist = bMatchMayExist;
+
+ // Save edit mode so that it can be restored when switching the view
+ // shell again.
+ pDrawViewShell = ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell);
+ OSL_ASSERT(pDrawViewShell.get()!=NULL);
+ if (pDrawViewShell.get() != NULL)
+ mpImpl->meOriginalEditMode = pDrawViewShell->GetEditMode();
+ }
+}
+
+
+
+
+void Outliner::SetPage (EditMode eEditMode, sal_uInt16 nPageIndex)
+{
+ if ( ! mbRestrictSearchToSelection)
+ {
+ ::boost::shared_ptr<DrawViewShell> pDrawViewShell(
+ ::boost::dynamic_pointer_cast<DrawViewShell>(mpViewShell));
+ OSL_ASSERT(pDrawViewShell.get()!=NULL);
+ if (pDrawViewShell.get() != NULL)
+ {
+ pDrawViewShell->ChangeEditMode(eEditMode, sal_False);
+ pDrawViewShell->SwitchPage(nPageIndex);
+ }
+ }
+}
+
+
+
+
+void Outliner::EnterEditMode (sal_Bool bGrabFocus)
+{
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (mbViewShellValid && pOutlinerView != NULL)
+ {
+ pOutlinerView->SetOutputArea( Rectangle( Point(), Size(1, 1)));
+ SetPaperSize( mpTextObj->GetLogicRect().GetSize() );
+ SdrPageView* pPV = mpView->GetSdrPageView();
+
+ // Make FuText the current function.
+ SfxUInt16Item aItem (SID_TEXTEDIT, 1);
+ mpViewShell->GetDispatcher()->
+ Execute(SID_TEXTEDIT, SFX_CALLMODE_SYNCHRON |
+ SFX_CALLMODE_RECORD, &aItem, 0L);
+
+ // To be consistent with the usual behaviour in the Office the text
+ // object that is put into edit mode would have also to be selected.
+ // Starting the text edit mode is not enough so we do it here by
+ // hand.
+ mbExpectingSelectionChangeEvent = true;
+ mpView->UnmarkAllObj (pPV);
+ mpView->MarkObj (mpTextObj, pPV);
+
+ if( mpTextObj )
+ mpTextObj->setActiveText( mnText );
+
+ // Turn on the edit mode for the text object.
+ mpView->SdrBeginTextEdit(mpTextObj, pPV, mpWindow, sal_True, this, pOutlinerView, sal_True, sal_True, bGrabFocus);
+
+ SetUpdateMode(sal_True);
+ mbFoundObject = sal_True;
+ }
+}
+
+
+
+
+/*************************************************************************
+|*
+|* SpellChecker: Error-LinkHdl
+|*
+\************************************************************************/
+
+IMPL_LINK_INLINE_START( Outliner, SpellError, void *, nLang )
+{
+ mbError = true;
+ String aError( SvtLanguageTable::GetLanguageString( (LanguageType)(sal_uLong)nLang ) );
+ ErrorHandler::HandleError(* new StringErrorInfo(
+ ERRCODE_SVX_LINGU_LANGUAGENOTEXISTS, aError) );
+ return 0;
+}
+IMPL_LINK_INLINE_END( Outliner, SpellError, void *, nLang )
+
+
+
+
+ESelection Outliner::GetSearchStartPosition (void)
+{
+ ESelection aPosition;
+ if (mbDirectionIsForward)
+ {
+ // The default constructor uses the beginning of the text as default.
+ aPosition = ESelection ();
+ }
+ else
+ {
+ // Retrieve the position after the last character in the last
+ // paragraph.
+ sal_uInt16 nParagraphCount = static_cast<sal_uInt16>(GetParagraphCount());
+ if (nParagraphCount == 0)
+ aPosition = ESelection();
+ else
+ {
+ xub_StrLen nLastParagraphLength = GetEditEngine().GetTextLen (
+ nParagraphCount-1);
+ aPosition = ESelection (nParagraphCount-1, nLastParagraphLength);
+ }
+ }
+
+ return aPosition;
+}
+
+
+
+
+bool Outliner::HasNoPreviousMatch (void)
+{
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+
+ DBG_ASSERT (pOutlinerView!=NULL, "outline view in Outliner::HasNoPreviousMatch is NULL");
+
+ // Detect whether the cursor stands at the beginning
+ // resp. at the end of the text.
+ return pOutlinerView->GetSelection().IsEqual(GetSearchStartPosition ()) == sal_True;
+}
+
+
+
+
+bool Outliner::HandleFailedSearch (void)
+{
+ bool bContinueSearch = false;
+
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL && mpSearchItem != NULL)
+ {
+ // Detect whether there is/may be a prior match. If there is then
+ // ask the user whether to wrap arround. Otherwise tell the user
+ // that there is no match.
+ if (HasNoPreviousMatch ())
+ {
+ // No match found in the whole presentation. Tell the user.
+ InfoBox aInfoBox (NULL,
+ String(SdResId(STR_SAR_NOT_FOUND)));
+ ShowModalMessageBox (aInfoBox);
+ }
+
+ else
+ {
+ // No further matches found. Ask the user whether to wrap
+ // arround and start again.
+ bContinueSearch = ShowWrapArroundDialog ();
+ }
+ }
+
+ return bContinueSearch;
+}
+
+
+SdrObject* Outliner::SetObject (
+ const ::sd::outliner::IteratorPosition& rPosition)
+{
+ SetViewMode (rPosition.mePageKind);
+ SetPage (rPosition.meEditMode, (sal_uInt16)rPosition.mnPageIndex);
+ mnText = rPosition.mnText;
+ return rPosition.mxObject.get();
+}
+
+
+
+
+void Outliner::SetViewShell (const ::boost::shared_ptr<ViewShell>& rpViewShell)
+{
+ if (mpViewShell != rpViewShell)
+ {
+ // Set the new view shell.
+ mpViewShell = rpViewShell;
+ // When the outline view is not owned by us then we have to clear
+ // that pointer so that the current one for the new view shell will
+ // be used (in ProvideOutlinerView).
+ // if ( ! mbOwnOutlineView)
+ // mpOutlineView = NULL;
+ if (mpViewShell.get() != NULL)
+ {
+ mpView = mpViewShell->GetView();
+
+ mpWindow = mpViewShell->GetActiveWindow();
+
+ mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow);
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ pOutlinerView->SetWindow(mpWindow);
+ }
+ else
+ {
+ mpView = NULL;
+ mpWindow = NULL;
+ }
+ }
+}
+
+
+
+
+void Outliner::HandleChangedSelection (void)
+{
+ maMarkListCopy.clear();
+ mbRestrictSearchToSelection = (mpView->AreObjectsMarked()==sal_True);
+ if (mbRestrictSearchToSelection)
+ {
+ // Make a copy of the current mark list.
+ const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+ sal_uLong nCount = rMarkList.GetMarkCount();
+ if (nCount > 0)
+ {
+ maMarkListCopy.clear();
+ maMarkListCopy.reserve (nCount);
+ for (sal_uLong i=0; i<nCount; i++)
+ maMarkListCopy.push_back (rMarkList.GetMark(i)->GetMarkedSdrObj ());
+ }
+ else
+ // No marked object. Is this case possible?
+ mbRestrictSearchToSelection = false;
+ }
+}
+
+
+
+
+
+void Outliner::StartConversion( sal_Int16 nSourceLanguage, sal_Int16 nTargetLanguage,
+ const Font *pTargetFont, sal_Int32 nOptions, sal_Bool bIsInteractive )
+{
+ sal_Bool bMultiDoc = mpViewShell->ISA(DrawViewShell);
+
+ meMode = TEXT_CONVERSION;
+ mbDirectionIsForward = true;
+ mpSearchItem = NULL;
+ mnConversionLanguage = nSourceLanguage;
+
+ BeginConversion();
+
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ {
+ pOutlinerView->StartTextConversion(
+ nSourceLanguage,
+ nTargetLanguage,
+ pTargetFont,
+ nOptions,
+ bIsInteractive,
+ bMultiDoc);
+ }
+
+ EndConversion();
+}
+
+
+
+
+/** Prepare to do a text conversion on the current text object. This
+ includes putting it into edit mode.
+*/
+void Outliner::PrepareConversion (void)
+{
+ SetUpdateMode(sal_True);
+ if( HasConvertibleTextPortion( mnConversionLanguage ) )
+ {
+ SetUpdateMode(sal_False);
+ mbStringFound = sal_True;
+ mbMatchMayExist = sal_True;
+
+ EnterEditMode ();
+
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False );
+ // Start seach at the right end of the current object's text
+ // depending on the search direction.
+// mpOutlineView->SetSelection (GetSearchStartPosition ());
+ }
+ else
+ {
+ SetUpdateMode(sal_False);
+ }
+}
+
+
+
+
+void Outliner::BeginConversion (void)
+{
+ SetRefDevice( SD_MOD()->GetRefDevice( *mpDrawDocument->GetDocSh() ) );
+
+ ViewShellBase* pBase = PTR_CAST(ViewShellBase, SfxViewShell::Current());
+ if (pBase != NULL)
+ SetViewShell (pBase->GetMainViewShell());
+
+ if (mpViewShell != NULL)
+ {
+ mbStringFound = sal_False;
+
+ // Supposed that we are not located at the very beginning/end of the
+ // document then there may be a match in the document prior/after
+ // the current position.
+ mbMatchMayExist = sal_True;
+
+ maObjectIterator = ::sd::outliner::Iterator();
+ maSearchStartPosition = ::sd::outliner::Iterator();
+ RememberStartPosition();
+
+ mpImpl->ProvideOutlinerView(*this, mpViewShell, mpWindow);
+
+ HandleChangedSelection ();
+ }
+ ClearModifyFlag();
+}
+
+
+
+
+void Outliner::EndConversion()
+{
+ EndSpelling();
+}
+
+
+
+
+sal_Bool Outliner::ConvertNextDocument()
+{
+ if( mpViewShell && mpViewShell->ISA(OutlineViewShell) )
+ return false;
+
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_True );
+
+ Initialize ( true );
+
+ OutlinerView* pOutlinerView = mpImpl->GetOutlinerView();
+ if (pOutlinerView != NULL)
+ {
+ mpWindow = mpViewShell->GetActiveWindow();
+ pOutlinerView->SetWindow(mpWindow);
+ }
+ ProvideNextTextObject ();
+
+ mpDrawDocument->GetDocSh()->SetWaitCursor( sal_False );
+ ClearModifyFlag();
+
+ // for text conversion we automaticly wrap around one
+ // time and stop at the start shape
+ if( mpFirstObj )
+ {
+ if( (mnText == 0) && (mpFirstObj == mpObj) )
+ return false;
+ }
+ else
+ {
+ mpFirstObj = mpObj;
+ }
+
+ return !mbEndOfSearch;
+}
+
+
+
+
+sal_uInt16 Outliner::ShowModalMessageBox (Dialog& rMessageBox)
+{
+ // We assume that the parent of the given messge box is NULL, i.e. it is
+ // modal with respect to the top application window. However, this
+ // does not affect the search dialog. Therefore we have to lock it here
+ // while the message box is being shown. We also have to take into
+ // account that we are called during a spell check and the search dialog
+ // is not available.
+ ::Window* pSearchDialog = NULL;
+ SfxChildWindow* pChildWindow = NULL;
+ switch (meMode)
+ {
+ case SEARCH:
+ pChildWindow = SfxViewFrame::Current()->GetChildWindow(
+ SvxSearchDialogWrapper::GetChildWindowId());
+ break;
+
+ case SPELL:
+ pChildWindow = SfxViewFrame::Current()->GetChildWindow(
+ SpellDialogChildWindow::GetChildWindowId());
+ break;
+
+ case TEXT_CONVERSION:
+ // There should no messages boxes be displayed while doing the
+ // hangul hanja conversion.
+ break;
+ }
+
+ if (pChildWindow != NULL)
+ pSearchDialog = pChildWindow->GetWindow();
+ if (pSearchDialog != NULL)
+ pSearchDialog->EnableInput(sal_False,sal_True);
+
+ sal_uInt16 nResult = rMessageBox.Execute();
+
+ // Unlock the search dialog.
+ if (pSearchDialog != NULL)
+ pSearchDialog->EnableInput(sal_True,sal_True);
+
+ return nResult;
+}
+
+
+
+
+//===== Outliner::Implementation ==============================================
+
+Outliner::Implementation::Implementation (void)
+ : meOriginalEditMode(EM_PAGE),
+ mbOwnOutlineView(false),
+ mpOutlineView(NULL)
+{
+}
+
+
+
+
+Outliner::Implementation::~Implementation (void)
+{
+ if (mbOwnOutlineView && mpOutlineView!=NULL)
+ {
+ mpOutlineView->SetWindow(NULL);
+ delete mpOutlineView;
+ mpOutlineView = NULL;
+ }
+}
+
+
+
+
+OutlinerView* Outliner::Implementation::GetOutlinerView ()
+{
+ return mpOutlineView;
+}
+
+
+
+
+/** We try to create a new OutlinerView only when there is none available,
+ either from an OutlinerViewShell or a previous call to
+ ProvideOutlinerView(). This is necessary to support the spell checker
+ which can not cope with exchanging the OutlinerView.
+*/
+void Outliner::Implementation::ProvideOutlinerView (
+ Outliner& rOutliner,
+ const ::boost::shared_ptr<ViewShell>& rpViewShell,
+ ::Window* pWindow)
+{
+ if (rpViewShell.get() != NULL)
+ {
+ switch (rpViewShell->GetShellType())
+ {
+ case ViewShell::ST_DRAW:
+ case ViewShell::ST_IMPRESS:
+ case ViewShell::ST_NOTES:
+ case ViewShell::ST_HANDOUT:
+ {
+ // Create a new outline view to do the search on.
+ bool bInsert = false;
+ if (mpOutlineView!=NULL && !mbOwnOutlineView)
+ mpOutlineView = NULL;
+ if (mpOutlineView == NULL)
+ {
+ mpOutlineView = new OutlinerView(&rOutliner, pWindow);
+ mbOwnOutlineView = true;
+ bInsert = true;
+ }
+ else
+ mpOutlineView->SetWindow(pWindow);
+ sal_uLong nStat = mpOutlineView->GetControlWord();
+ nStat &= ~EV_CNTRL_AUTOSCROLL;
+ mpOutlineView->SetControlWord(nStat);
+ if (bInsert)
+ rOutliner.InsertView( mpOutlineView );
+ rOutliner.SetUpdateMode(sal_False);
+ mpOutlineView->SetOutputArea (Rectangle (Point(), Size(1, 1)));
+ rOutliner.SetPaperSize( Size(1, 1) );
+ rOutliner.SetText( String(), rOutliner.GetParagraph( 0 ) );
+
+ meOriginalEditMode =
+ ::boost::static_pointer_cast<DrawViewShell>(rpViewShell)->GetEditMode();
+ }
+ break;
+
+ case ViewShell::ST_OUTLINE:
+ {
+ if (mpOutlineView!=NULL && mbOwnOutlineView)
+ delete mpOutlineView;
+ mpOutlineView = rOutliner.GetView(0);
+ mbOwnOutlineView = false;
+ }
+ break;
+
+ default:
+ case ViewShell::ST_NONE:
+ case ViewShell::ST_PRESENTATION:
+ // Ignored
+ break;
+ }
+ }
+}
+
+
+
+
+void Outliner::Implementation::ReleaseOutlinerView (void)
+{
+ if (mbOwnOutlineView)
+ {
+ OutlinerView* pView = mpOutlineView;
+ mpOutlineView = NULL;
+ mbOwnOutlineView = false;
+ if (pView != NULL)
+ {
+ pView->SetWindow(NULL);
+ delete pView;
+ }
+ }
+ else
+ {
+ mpOutlineView = NULL;
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/OutlinerIterator.cxx b/sd/source/ui/view/OutlinerIterator.cxx
new file mode 100755
index 000000000000..d2f1a97ad698
--- /dev/null
+++ b/sd/source/ui/view/OutlinerIterator.cxx
@@ -0,0 +1,898 @@
+/*************************************************************************
+ *
+ * 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 "OutlinerIterator.hxx"
+#include "OutlinerIteratorImpl.hxx"
+#include <svx/svditer.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include "Outliner.hxx"
+
+#include "drawdoc.hxx"
+#include "DrawViewShell.hxx"
+#include "drawview.hxx"
+#include "sdpage.hxx"
+#ifndef SD_FRAME_VIEW
+#include "FrameView.hxx"
+#endif
+#include "DrawDocShell.hxx"
+#include "Window.hxx"
+
+namespace sd { namespace outliner {
+
+
+//===== IteratorPosition ======================================================
+
+IteratorPosition::IteratorPosition (void)
+: mnText(0)
+, mnPageIndex(-1)
+, mePageKind(PK_STANDARD)
+, meEditMode(EM_PAGE)
+{
+}
+
+IteratorPosition::IteratorPosition (const IteratorPosition& aPosition)
+: mxObject(aPosition.mxObject)
+, mnText(aPosition.mnText)
+, mnPageIndex(aPosition.mnPageIndex)
+, mePageKind(aPosition.mePageKind)
+, meEditMode(aPosition.meEditMode)
+{
+}
+
+IteratorPosition::~IteratorPosition (void)
+{
+}
+
+IteratorPosition& IteratorPosition::operator= (const IteratorPosition& aPosition)
+{
+ mxObject = aPosition.mxObject;
+ mnText = aPosition.mnText;
+ mnPageIndex = aPosition.mnPageIndex;
+ mePageKind = aPosition.mePageKind;
+ meEditMode = aPosition.meEditMode;
+ return *this;
+}
+
+bool IteratorPosition::operator== (const IteratorPosition& aPosition) const
+{
+ return mxObject.get() == aPosition.mxObject.get()
+ && mnText == aPosition.mnText
+ && mnPageIndex == aPosition.mnPageIndex
+ && mePageKind == aPosition.mePageKind
+ && meEditMode == aPosition.meEditMode;
+}
+
+
+
+
+//===== Iterator ==============================================================
+
+Iterator::Iterator (void)
+{
+ mpIterator = NULL;
+}
+
+Iterator::Iterator (const Iterator& rIterator)
+{
+ mpIterator = rIterator.mpIterator->Clone();
+}
+
+Iterator::Iterator (IteratorImplBase* pObject)
+{
+ mpIterator = pObject;
+}
+
+Iterator::~Iterator (void)
+{
+ delete mpIterator;
+}
+
+Iterator& Iterator::operator= (const Iterator& rIterator)
+{
+ if (this != &rIterator)
+ {
+ delete mpIterator;
+ if (rIterator.mpIterator != NULL)
+ mpIterator = rIterator.mpIterator->Clone();
+ else
+ mpIterator = NULL;
+ }
+ return *this;
+}
+
+const IteratorPosition& Iterator::operator* () const
+{
+ DBG_ASSERT (mpIterator!=NULL, "::sd::outliner::Iterator::operator* : missing implementation object");
+ return mpIterator->GetPosition();
+}
+
+Iterator& Iterator::operator++ ()
+{
+ if (mpIterator!=NULL)
+ mpIterator->GotoNextText();
+ return *this;
+}
+
+Iterator Iterator::operator++ (int)
+{
+ Iterator aTmp (*this);
+ if (mpIterator!=NULL)
+ mpIterator->GotoNextText();
+ return aTmp;
+}
+
+bool Iterator::operator== (const Iterator& rIterator)
+{
+ if (mpIterator == NULL || rIterator.mpIterator==NULL)
+ return mpIterator == rIterator.mpIterator;
+ else
+ return *mpIterator == *rIterator.mpIterator;
+}
+
+bool Iterator::operator!= (const Iterator& rIterator)
+{
+ return ! operator==(rIterator);
+}
+
+void Iterator::Reverse (void)
+{
+ if (mpIterator != NULL)
+ mpIterator->Reverse();
+}
+
+//===== IteratorFactory =======================================================
+
+OutlinerContainer::OutlinerContainer (Outliner* pOutliner)
+: mpOutliner(pOutliner)
+{
+}
+
+Iterator OutlinerContainer::begin (void)
+{
+ return CreateIterator (BEGIN);
+}
+
+Iterator OutlinerContainer::end (void)
+{
+ return CreateIterator (END);
+}
+
+Iterator OutlinerContainer::current (void)
+{
+ return CreateIterator (CURRENT);
+}
+
+
+Iterator OutlinerContainer::CreateIterator (IteratorLocation aLocation)
+{
+ // Decide on certain features of the outliner which kind of iterator to
+ // use.
+ if (mpOutliner->mbRestrictSearchToSelection)
+ // There is a selection. Search only in this.
+ return CreateSelectionIterator (
+ mpOutliner->maMarkListCopy,
+ mpOutliner->mpDrawDocument,
+ mpOutliner->mpViewShell,
+ mpOutliner->mbDirectionIsForward,
+ aLocation);
+ else
+ // Search in the whole document.
+ return CreateDocumentIterator (
+ mpOutliner->mpDrawDocument,
+ mpOutliner->mpViewShell,
+ mpOutliner->mbDirectionIsForward,
+ aLocation);
+}
+
+Iterator OutlinerContainer::CreateSelectionIterator (
+ const ::std::vector<SdrObjectWeakRef>& rObjectList,
+ SdDrawDocument* pDocument,
+ const ::boost::shared_ptr<ViewShell>& rpViewShell,
+ bool bDirectionIsForward,
+ IteratorLocation aLocation)
+{
+ OSL_ASSERT(rpViewShell.get());
+
+ sal_Int32 nObjectIndex;
+
+ if (bDirectionIsForward)
+ switch (aLocation)
+ {
+ case CURRENT:
+ case BEGIN:
+ default:
+ nObjectIndex = 0;
+ break;
+ case END:
+ nObjectIndex = rObjectList.size();
+ break;
+ }
+ else
+ switch (aLocation)
+ {
+ case CURRENT:
+ case BEGIN:
+ default:
+ nObjectIndex = rObjectList.size()-1;
+ break;
+ case END:
+ nObjectIndex = -1;
+ break;
+ }
+
+ return Iterator (new SelectionIteratorImpl (
+ rObjectList, nObjectIndex, pDocument, rpViewShell, bDirectionIsForward));
+}
+
+Iterator OutlinerContainer::CreateDocumentIterator (
+ SdDrawDocument* pDocument,
+ const ::boost::shared_ptr<ViewShell>& rpViewShell,
+ bool bDirectionIsForward,
+ IteratorLocation aLocation)
+{
+ OSL_ASSERT(rpViewShell.get());
+
+ PageKind ePageKind;
+ EditMode eEditMode;
+
+ switch (aLocation)
+ {
+ case BEGIN:
+ default:
+ if (bDirectionIsForward)
+ {
+ ePageKind = PK_STANDARD;
+ eEditMode = EM_PAGE;
+ }
+ else
+ {
+ ePageKind = PK_HANDOUT;
+ eEditMode = EM_MASTERPAGE;
+ }
+ break;
+
+ case END:
+ if (bDirectionIsForward)
+ {
+ ePageKind = PK_HANDOUT;
+ eEditMode = EM_MASTERPAGE;
+ }
+ else
+ {
+ ePageKind = PK_STANDARD;
+ eEditMode = EM_PAGE;
+ }
+ break;
+
+ case CURRENT:
+ const ::boost::shared_ptr<DrawViewShell> pDrawViewShell(
+ ::boost::dynamic_pointer_cast<DrawViewShell>(rpViewShell));
+ if (pDrawViewShell.get())
+ {
+ ePageKind = pDrawViewShell->GetPageKind();
+ eEditMode = pDrawViewShell->GetEditMode();
+ }
+ else
+ {
+ ePageKind = PK_STANDARD;
+ eEditMode = EM_PAGE;
+ }
+ break;
+ }
+
+ sal_Int32 nPageIndex = GetPageIndex (pDocument, rpViewShell,
+ ePageKind, eEditMode, bDirectionIsForward, aLocation);
+
+ return Iterator (
+ new DocumentIteratorImpl (nPageIndex, ePageKind, eEditMode,
+ pDocument, rpViewShell, bDirectionIsForward));
+}
+
+sal_Int32 OutlinerContainer::GetPageIndex (
+ SdDrawDocument* pDocument,
+ const ::boost::shared_ptr<ViewShell>& rpViewShell,
+ PageKind ePageKind,
+ EditMode eEditMode,
+ bool bDirectionIsForward,
+ IteratorLocation aLocation)
+{
+ OSL_ASSERT(rpViewShell);
+
+ sal_Int32 nPageIndex;
+ sal_Int32 nPageCount;
+
+ const ::boost::shared_ptr<DrawViewShell> pDrawViewShell(
+ ::boost::dynamic_pointer_cast<DrawViewShell>(rpViewShell));
+
+ switch (eEditMode)
+ {
+ case EM_PAGE:
+ nPageCount = pDocument->GetSdPageCount (ePageKind);
+ break;
+ case EM_MASTERPAGE:
+ nPageCount = pDocument->GetMasterSdPageCount(ePageKind);
+ break;
+ default:
+ nPageCount = 0;
+ }
+
+ switch (aLocation)
+ {
+ case CURRENT:
+ if (pDrawViewShell.get())
+ nPageIndex = pDrawViewShell->GetCurPageId() - 1;
+ else
+ {
+ const SdPage* pPage = rpViewShell->GetActualPage();
+ if (pPage != NULL)
+ nPageIndex = (pPage->GetPageNum()-1)/2;
+ else
+ nPageIndex = 0;
+ }
+ break;
+
+ case BEGIN:
+ default:
+ if (bDirectionIsForward)
+ nPageIndex = 0;
+ else
+ nPageIndex = nPageCount-1;
+ break;
+
+ case END:
+ if (bDirectionIsForward)
+ nPageIndex = nPageCount;
+ else
+ nPageIndex = -1;
+ break;
+ }
+
+ return nPageIndex;
+}
+
+
+
+
+//===== IteratorImplBase ====================================================
+
+IteratorImplBase::IteratorImplBase(SdDrawDocument* pDocument,
+ const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
+ bool bDirectionIsForward)
+: maPosition()
+, mpDocument (pDocument)
+, mpViewShellWeak (rpViewShellWeak)
+, mbDirectionIsForward (bDirectionIsForward)
+{
+ ::boost::shared_ptr<DrawViewShell> pDrawViewShell;
+ if ( ! mpViewShellWeak.expired())
+ pDrawViewShell = ::boost::dynamic_pointer_cast<DrawViewShell>(rpViewShellWeak.lock());
+
+ if (pDrawViewShell.get())
+ {
+ maPosition.mePageKind = pDrawViewShell->GetPageKind();
+ maPosition.meEditMode = pDrawViewShell->GetEditMode();
+ }
+ else
+ {
+ maPosition.mePageKind = PK_STANDARD;
+ maPosition.meEditMode = EM_PAGE;
+ }
+}
+
+IteratorImplBase::IteratorImplBase( SdDrawDocument* pDocument,
+ const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
+ bool bDirectionIsForward, PageKind ePageKind, EditMode eEditMode)
+: maPosition()
+, mpDocument (pDocument)
+, mpViewShellWeak (rpViewShellWeak)
+, mbDirectionIsForward (bDirectionIsForward)
+{
+ maPosition.mePageKind = ePageKind;
+ maPosition.meEditMode = eEditMode;
+}
+
+IteratorImplBase::~IteratorImplBase (void)
+{}
+
+bool IteratorImplBase::operator== (const IteratorImplBase& rIterator) const
+{
+ return maPosition == rIterator.maPosition;
+}
+
+bool IteratorImplBase::IsEqual (const IteratorImplBase& rIterator, IteratorType ) const
+{
+ // When this method is executed instead of the ones from derived classes
+ // then the argument is of another type then the object itself. In this
+ // just compare the position objects.
+ return maPosition == rIterator.maPosition;
+}
+
+const IteratorPosition& IteratorImplBase::GetPosition (void)
+{
+ return maPosition;
+}
+
+
+
+
+IteratorImplBase* IteratorImplBase::Clone (IteratorImplBase* pObject) const
+{
+ if (pObject != NULL)
+ {
+ pObject->maPosition = maPosition;
+ pObject->mpDocument = mpDocument;
+ pObject->mpViewShellWeak = mpViewShellWeak;
+ pObject->mbDirectionIsForward = mbDirectionIsForward;
+ }
+ return pObject;
+}
+
+
+
+void IteratorImplBase::Reverse (void)
+{
+ mbDirectionIsForward = ! mbDirectionIsForward;
+}
+
+
+
+//===== SelectionIteratorImpl ===========================================
+
+SelectionIteratorImpl::SelectionIteratorImpl (
+ const ::std::vector<SdrObjectWeakRef>& rObjectList,
+ sal_Int32 nObjectIndex,
+ SdDrawDocument* pDocument,
+ const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
+ bool bDirectionIsForward)
+ : IteratorImplBase (pDocument, rpViewShellWeak, bDirectionIsForward),
+ mrObjectList(rObjectList),
+ mnObjectIndex(nObjectIndex)
+{
+}
+
+SelectionIteratorImpl::~SelectionIteratorImpl (void)
+{}
+
+IteratorImplBase* SelectionIteratorImpl::Clone (IteratorImplBase* pObject) const
+{
+ SelectionIteratorImpl* pIterator = static_cast<SelectionIteratorImpl*>(pObject);
+ if (pIterator == NULL)
+ pIterator = new SelectionIteratorImpl (
+ mrObjectList, mnObjectIndex, mpDocument, mpViewShellWeak, mbDirectionIsForward);
+ return pIterator;
+}
+
+
+void SelectionIteratorImpl::GotoNextText (void)
+{
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mrObjectList.at(mnObjectIndex).get() );
+ if (mbDirectionIsForward)
+ {
+ if( pTextObj )
+ {
+ ++maPosition.mnText;
+ if( maPosition.mnText >= pTextObj->getTextCount() )
+ {
+ maPosition.mnText = 0;
+ ++mnObjectIndex;
+ }
+ }
+ else
+ {
+ ++mnObjectIndex;
+ }
+ }
+ else
+ {
+ if( pTextObj )
+ {
+ --maPosition.mnText;
+ if( maPosition.mnText < 0 )
+ {
+ maPosition.mnText = -1;
+ --mnObjectIndex;
+ }
+ }
+ else
+ {
+ --mnObjectIndex;
+ maPosition.mnText = -1;
+ }
+
+ if( (maPosition.mnText == -1) && (mnObjectIndex >= 0) )
+ {
+ pTextObj = dynamic_cast< SdrTextObj* >( mrObjectList.at(mnObjectIndex).get() );
+ if( pTextObj )
+ maPosition.mnText = pTextObj->getTextCount() - 1;
+ }
+
+ if( maPosition.mnText == -1 )
+ maPosition.mnText = 0;
+ }
+}
+
+
+const IteratorPosition& SelectionIteratorImpl::GetPosition (void)
+{
+ maPosition.mxObject = mrObjectList.at(mnObjectIndex);
+
+ return maPosition;
+}
+
+
+bool SelectionIteratorImpl::operator== (const IteratorImplBase& rIterator) const
+{
+ return rIterator.IsEqual (*this, SELECTION);
+}
+
+
+bool SelectionIteratorImpl::IsEqual (
+ const IteratorImplBase& rIterator,
+ IteratorType aType) const
+{
+ if (aType == SELECTION)
+ {
+ const SelectionIteratorImpl* pSelectionIterator =
+ static_cast<const SelectionIteratorImpl*>(&rIterator);
+ return mpDocument == pSelectionIterator->mpDocument
+ && mnObjectIndex == pSelectionIterator->mnObjectIndex;
+ }
+ else
+ return false;
+}
+
+
+
+
+//===== ViewIteratorImpl ================================================
+
+ViewIteratorImpl::ViewIteratorImpl (
+ sal_Int32 nPageIndex,
+ SdDrawDocument* pDocument,
+ const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
+ bool bDirectionIsForward)
+ : IteratorImplBase (pDocument, rpViewShellWeak, bDirectionIsForward),
+ mbPageChangeOccured(false),
+ mpPage(NULL),
+ mpObjectIterator(NULL)
+{
+ SetPage (nPageIndex);
+}
+
+
+
+
+ViewIteratorImpl::ViewIteratorImpl (
+ sal_Int32 nPageIndex,
+ SdDrawDocument* pDocument,
+ const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
+ bool bDirectionIsForward,
+ PageKind ePageKind,
+ EditMode eEditMode)
+ : IteratorImplBase (pDocument, rpViewShellWeak, bDirectionIsForward, ePageKind, eEditMode),
+ mbPageChangeOccured(false),
+ mpPage(NULL),
+ mpObjectIterator(NULL)
+{
+ SetPage (nPageIndex);
+}
+
+
+
+
+ViewIteratorImpl::~ViewIteratorImpl (void)
+{
+}
+
+
+
+
+IteratorImplBase* ViewIteratorImpl::Clone (IteratorImplBase* pObject) const
+{
+
+ ViewIteratorImpl* pIterator = static_cast<ViewIteratorImpl*>(pObject);
+ if (pIterator == NULL)
+ pIterator = new ViewIteratorImpl (
+ maPosition.mnPageIndex, mpDocument, mpViewShellWeak, mbDirectionIsForward);
+
+ IteratorImplBase::Clone (pObject);
+
+ if (mpObjectIterator != NULL)
+ {
+ pIterator->mpObjectIterator = new SdrObjListIter(*mpPage, IM_DEEPNOGROUPS, !mbDirectionIsForward);
+
+ // No direct way to set the object iterator to the current object.
+ pIterator->maPosition.mxObject.reset(NULL);
+ while (pIterator->mpObjectIterator->IsMore() && pIterator->maPosition.mxObject!=maPosition.mxObject)
+ pIterator->maPosition.mxObject.reset(pIterator->mpObjectIterator->Next());
+ }
+ else
+ pIterator->mpObjectIterator = NULL;
+
+ return pIterator;
+}
+
+
+
+void ViewIteratorImpl::GotoNextText(void)
+{
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() );
+ if( pTextObj )
+ {
+ if (mbDirectionIsForward)
+ {
+ ++maPosition.mnText;
+ if( maPosition.mnText < pTextObj->getTextCount() )
+ return;
+ }
+ else
+ {
+ --maPosition.mnText;
+ if( maPosition.mnText >= 0 )
+ return;
+ }
+ }
+
+ if (mpObjectIterator != NULL && mpObjectIterator->IsMore())
+ maPosition.mxObject.reset(mpObjectIterator->Next());
+ else
+ maPosition.mxObject.reset(NULL);
+
+ if (!maPosition.mxObject.is() )
+ {
+ if (mbDirectionIsForward)
+ SetPage (maPosition.mnPageIndex+1);
+ else
+ SetPage (maPosition.mnPageIndex-1);
+
+ if (mpPage != NULL)
+ mpObjectIterator = new SdrObjListIter(*mpPage, IM_DEEPNOGROUPS, !mbDirectionIsForward);
+ if (mpObjectIterator!=NULL && mpObjectIterator->IsMore())
+ maPosition.mxObject.reset(mpObjectIterator->Next());
+ else
+ maPosition.mxObject.reset(NULL);
+ }
+
+ maPosition.mnText = 0;
+ if( !mbDirectionIsForward && maPosition.mxObject.is() )
+ {
+ pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() );
+ if( pTextObj )
+ maPosition.mnText = pTextObj->getTextCount() - 1;
+ }
+}
+
+
+
+
+void ViewIteratorImpl::SetPage (sal_Int32 nPageIndex)
+{
+ mbPageChangeOccured = (maPosition.mnPageIndex!=nPageIndex);
+ if (mbPageChangeOccured)
+ {
+ maPosition.mnPageIndex = nPageIndex;
+
+ sal_Int32 nPageCount;
+ if (maPosition.meEditMode == EM_PAGE)
+ nPageCount = mpDocument->GetSdPageCount(maPosition.mePageKind);
+ else
+ nPageCount = mpDocument->GetMasterSdPageCount(
+ maPosition.mePageKind);
+
+ // Get page pointer. Here we have three cases: regular pages,
+ // master pages and invalid page indices. The later ones are not
+ // errors but the effect of the iterator advancing to the next page
+ // and going past the last one. This dropping of the rim at the far
+ // side is detected here and has to be reacted to by the caller.
+ if (nPageIndex>=0 && nPageIndex < nPageCount)
+ {
+ if (maPosition.meEditMode == EM_PAGE)
+ mpPage = mpDocument->GetSdPage (
+ (sal_uInt16)nPageIndex,
+ maPosition.mePageKind);
+ else
+ mpPage = mpDocument->GetMasterSdPage (
+ (sal_uInt16)nPageIndex,
+ maPosition.mePageKind);
+ }
+ else
+ mpPage = NULL;
+ }
+
+ // Set up object list iterator.
+ if (mpPage != NULL)
+ mpObjectIterator = new SdrObjListIter(*mpPage, IM_DEEPNOGROUPS, ! mbDirectionIsForward);
+ else
+ mpObjectIterator = NULL;
+
+ // Get object pointer.
+ if (mpObjectIterator!=NULL && mpObjectIterator->IsMore())
+ maPosition.mxObject.reset( mpObjectIterator->Next() );
+ else
+ maPosition.mxObject.reset( NULL );
+
+ maPosition.mnText = 0;
+ if( !mbDirectionIsForward && maPosition.mxObject.is() )
+ {
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( maPosition.mxObject.get() );
+ if( pTextObj )
+ maPosition.mnText = pTextObj->getTextCount() - 1;
+ }
+
+}
+
+
+
+
+void ViewIteratorImpl::Reverse (void)
+{
+ IteratorImplBase::Reverse ();
+
+ // Create reversed object list iterator.
+ if (mpObjectIterator != NULL)
+ delete mpObjectIterator;
+ if (mpPage != NULL)
+ mpObjectIterator = new SdrObjListIter(*mpPage, IM_DEEPNOGROUPS, ! mbDirectionIsForward);
+ else
+ mpObjectIterator = NULL;
+
+ // Move iterator to the current object.
+ SdrObjectWeakRef xObject = maPosition.mxObject;
+ maPosition.mxObject.reset(NULL);
+ while (mpObjectIterator->IsMore() && maPosition.mxObject != xObject)
+ maPosition.mxObject.reset(mpObjectIterator->Next());
+}
+
+
+
+
+//===== DocumentIteratorImpl ============================================
+
+DocumentIteratorImpl::DocumentIteratorImpl (
+ sal_Int32 nPageIndex,
+ PageKind ePageKind, EditMode eEditMode,
+ SdDrawDocument* pDocument,
+ const ::boost::weak_ptr<ViewShell>& rpViewShellWeak,
+ bool bDirectionIsForward)
+ : ViewIteratorImpl (nPageIndex, pDocument, rpViewShellWeak, bDirectionIsForward,
+ ePageKind, eEditMode)
+{
+ if (eEditMode == EM_PAGE)
+ mnPageCount = pDocument->GetSdPageCount (ePageKind);
+ else
+ mnPageCount = pDocument->GetMasterSdPageCount(ePageKind);
+}
+
+
+
+
+DocumentIteratorImpl::~DocumentIteratorImpl (void)
+{}
+
+
+
+
+IteratorImplBase* DocumentIteratorImpl::Clone (IteratorImplBase* pObject) const
+{
+ DocumentIteratorImpl* pIterator = static_cast<DocumentIteratorImpl*>(pObject);
+ if (pIterator == NULL)
+ pIterator = new DocumentIteratorImpl (
+ maPosition.mnPageIndex, maPosition.mePageKind, maPosition.meEditMode,
+ mpDocument, mpViewShellWeak, mbDirectionIsForward);
+ // Finish the cloning.
+ return ViewIteratorImpl::Clone (pIterator);
+}
+
+
+
+
+void DocumentIteratorImpl::GotoNextText (void)
+{
+ bool bSetToOnePastLastPage = false;
+ bool bViewChanged = false;
+
+ ViewIteratorImpl::GotoNextText();
+
+ if (mbDirectionIsForward)
+ {
+ if (maPosition.mnPageIndex >= mnPageCount)
+ {
+ // Switch to master page.
+ if (maPosition.meEditMode == EM_PAGE)
+ {
+ maPosition.meEditMode = EM_MASTERPAGE;
+ SetPage (0);
+ }
+
+ // Switch to next view mode.
+ else
+ {
+ if (maPosition.mePageKind == PK_HANDOUT)
+ // Not really necessary but makes things more clear.
+ bSetToOnePastLastPage = true;
+ else
+ {
+ maPosition.meEditMode = EM_PAGE;
+ if (maPosition.mePageKind == PK_STANDARD)
+ maPosition.mePageKind = PK_NOTES;
+ else if (maPosition.mePageKind == PK_NOTES)
+ maPosition.mePageKind = PK_HANDOUT;
+ SetPage (0);
+ }
+ }
+ bViewChanged = true;
+ }
+ }
+ else
+ if (maPosition.mnPageIndex < 0)
+ {
+ // Switch from master pages to draw pages.
+ if (maPosition.meEditMode == EM_MASTERPAGE)
+ {
+ maPosition.meEditMode = EM_PAGE;
+ bSetToOnePastLastPage = true;
+ }
+
+ // Switch to previous view mode.
+ else
+ {
+ if (maPosition.mePageKind == PK_STANDARD)
+ SetPage (-1);
+ else
+ {
+ maPosition.meEditMode = EM_MASTERPAGE;
+ if (maPosition.mePageKind == PK_HANDOUT)
+ maPosition.mePageKind = PK_NOTES;
+ else if (maPosition.mePageKind == PK_NOTES)
+ maPosition.mePageKind = PK_STANDARD;
+ bSetToOnePastLastPage = true;
+ }
+ }
+ bViewChanged = true;
+ }
+
+ if (bViewChanged)
+ {
+ // Get new page count;
+ sal_Int32 nPageCount;
+ if (maPosition.meEditMode == EM_PAGE)
+ nPageCount = mpDocument->GetSdPageCount (maPosition.mePageKind);
+ else
+ nPageCount = mpDocument->GetMasterSdPageCount(maPosition.mePageKind);
+
+ // Now that we know the number of pages we can set the current page index.
+ if (bSetToOnePastLastPage)
+ SetPage (nPageCount);
+ }
+}
+
+
+} } // end of namespace ::sd::outliner
diff --git a/sd/source/ui/view/PresentationViewShellBase.cxx b/sd/source/ui/view/PresentationViewShellBase.cxx
new file mode 100755
index 000000000000..77a9e125d551
--- /dev/null
+++ b/sd/source/ui/view/PresentationViewShellBase.cxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * 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 "PresentationViewShellBase.hxx"
+#include "sdresid.hxx"
+#include "DrawDocShell.hxx"
+#include "strings.hrc"
+#include "UpdateLockManager.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include "framework/PresentationModule.hxx"
+
+#include <sfx2/viewfrm.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace sd {
+
+class DrawDocShell;
+
+TYPEINIT1(PresentationViewShellBase, ViewShellBase);
+
+// We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
+// new PresentationViewShellBase object has been constructed.
+
+SfxViewFactory* PresentationViewShellBase::pFactory;
+SfxViewShell* __EXPORT PresentationViewShellBase::CreateInstance (
+ SfxViewFrame *_pFrame, SfxViewShell *pOldView)
+{
+ PresentationViewShellBase* pBase =
+ new PresentationViewShellBase(_pFrame, pOldView);
+ pBase->LateInit(framework::FrameworkHelper::msPresentationViewURL);
+ return pBase;
+}
+void PresentationViewShellBase::RegisterFactory( sal_uInt16 nPrio )
+{
+ pFactory = new SfxViewFactory(
+ &CreateInstance,&InitFactory,nPrio,"FullScreenPresentation");
+ InitFactory();
+}
+void PresentationViewShellBase::InitFactory()
+{
+ SFX_VIEW_REGISTRATION(DrawDocShell);
+}
+
+
+
+
+PresentationViewShellBase::PresentationViewShellBase (
+ SfxViewFrame* _pFrame,
+ SfxViewShell* pOldShell)
+ : ViewShellBase (_pFrame, pOldShell)
+{
+ GetUpdateLockManager()->Disable();
+
+ // Hide the automatic (non-context sensitive) tool bars.
+ if (_pFrame!=NULL)
+ {
+ Reference<beans::XPropertySet> xFrameSet (
+ _pFrame->GetFrame().GetFrameInterface(),
+ UNO_QUERY);
+ if (xFrameSet.is())
+ {
+ Reference<beans::XPropertySet> xLayouterSet (
+ xFrameSet->getPropertyValue(::rtl::OUString::createFromAscii("LayoutManager")),
+ UNO_QUERY);
+ if (xLayouterSet.is())
+ {
+ xLayouterSet->setPropertyValue(
+ ::rtl::OUString::createFromAscii("AutomaticToolbars"),
+ makeAny(sal_False));
+ }
+ }
+ }
+}
+
+
+
+
+PresentationViewShellBase::~PresentationViewShellBase (void)
+{
+}
+
+
+
+void PresentationViewShellBase::InitializeFramework (void)
+{
+ com::sun::star::uno::Reference<com::sun::star::frame::XController>
+ xController (GetController());
+ sd::framework::PresentationModule::Initialize(xController);
+}
+
+} // end of namespace sd
+
diff --git a/sd/source/ui/view/SlideSorterViewShellBase.cxx b/sd/source/ui/view/SlideSorterViewShellBase.cxx
new file mode 100755
index 000000000000..be8e5907ed4e
--- /dev/null
+++ b/sd/source/ui/view/SlideSorterViewShellBase.cxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * 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 "SlideSorterViewShellBase.hxx"
+#include "sdresid.hxx"
+#include "DrawDocShell.hxx"
+#include "strings.hrc"
+#include "framework/FrameworkHelper.hxx"
+
+namespace sd {
+
+class DrawDocShell;
+
+TYPEINIT1(SlideSorterViewShellBase, ViewShellBase);
+
+// We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
+// new SlideSorterViewShellBase object has been constructed.
+
+SfxViewFactory* SlideSorterViewShellBase::pFactory;
+SfxViewShell* __EXPORT SlideSorterViewShellBase::CreateInstance (
+ SfxViewFrame *pFrame, SfxViewShell *pOldView)
+{
+ SlideSorterViewShellBase* pBase = new SlideSorterViewShellBase(pFrame, pOldView);
+ pBase->LateInit(framework::FrameworkHelper::msSlideSorterURL);
+ return pBase;
+}
+
+
+
+
+void SlideSorterViewShellBase::RegisterFactory( sal_uInt16 nPrio )
+{
+ pFactory = new SfxViewFactory(
+ &CreateInstance,&InitFactory,nPrio,"SlideSorter");
+ InitFactory();
+}
+
+
+
+
+void SlideSorterViewShellBase::InitFactory()
+{
+ SFX_VIEW_REGISTRATION(DrawDocShell);
+}
+
+
+
+
+
+
+
+SlideSorterViewShellBase::SlideSorterViewShellBase (
+ SfxViewFrame* _pFrame,
+ SfxViewShell* pOldShell)
+ : ImpressViewShellBase (_pFrame, pOldShell)
+{
+}
+
+
+
+
+SlideSorterViewShellBase::~SlideSorterViewShellBase (void)
+{
+}
+
+
+
+
+} // end of namespace sd
+
diff --git a/sd/source/ui/view/ToolBarManager.cxx b/sd/source/ui/view/ToolBarManager.cxx
new file mode 100755
index 000000000000..ed13049feb4f
--- /dev/null
+++ b/sd/source/ui/view/ToolBarManager.cxx
@@ -0,0 +1,1697 @@
+/*************************************************************************
+ *
+ * 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 "ToolBarManager.hxx"
+
+#include "DrawViewShell.hxx"
+#include "EventMultiplexer.hxx"
+#include "ViewShellBase.hxx"
+#include "ViewShellManager.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/ui/UIElementType.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/eitem.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+#include <tools/link.hxx>
+
+#include <map>
+#include <vector>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+#undef VERBOSE
+
+#undef OUSTRING // Remove definition made in the SFX
+#define OUSTRING(s) (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s)))
+
+namespace {
+
+using namespace sd;
+
+class ToolBarRules;
+
+/** Lock of the frame::XLayoutManager.
+*/
+class LayouterLock
+{
+public:
+ LayouterLock (const Reference<frame::XLayoutManager>& rxLayouter);
+ ~LayouterLock (void);
+private:
+ Reference<frame::XLayoutManager> mxLayouter;
+};
+
+
+typedef ::std::vector<rtl::OUString> NameList;
+
+/** Store a list of tool bars for each of the tool bar groups. From
+ this the list of requested tool bars is built.
+*/
+class ToolBarList
+{
+public:
+ ToolBarList (void);
+
+ void ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup);
+ void AddToolBar (sd::ToolBarManager::ToolBarGroup eGroup, const ::rtl::OUString& rsName);
+ bool RemoveToolBar (sd::ToolBarManager::ToolBarGroup eGroup, const ::rtl::OUString& rsName);
+
+ void GetToolBarsToActivate (NameList& rToolBars) const;
+ void GetToolBarsToDeactivate (NameList& rToolBars) const;
+
+ void MarkToolBarAsActive (const ::rtl::OUString& rsName);
+ void MarkToolBarAsNotActive (const ::rtl::OUString& rsName);
+ void MarkAllToolBarsAsNotActive (void);
+
+private:
+ typedef ::std::map<sd::ToolBarManager::ToolBarGroup,NameList> Groups;
+ Groups maGroups;
+ NameList maActiveToolBars;
+
+ void MakeRequestedToolBarList (NameList& rToolBars) const;
+};
+
+
+
+
+/** Manage tool bars that are implemented as sub shells of a view shell.
+ The typical procedure of updating the sub shells of a view shell is to
+ rebuild a list of sub shells that the caller would like to have active.
+ The methods ClearGroup() and AddShellId() allow the caller to do that. A
+ final call to UpdateShells() activates the requested shells that are not
+ active and deactivates the active shells that are not requested .
+
+ This is done by maintaining two lists. One (the current list)
+ reflects the current state. The other (the requested list) contains the
+ currently requested shells. UpdateShells() makes the requested
+ list the current list and clears the current list.
+
+ Each shell belongs to one group. Different groups can be modified
+ seperately.
+*/
+class ToolBarShellList
+{
+public:
+ /** Create a new object with an empty current list and an empty
+ requested list.
+ */
+ ToolBarShellList (void);
+
+ /** Remove all shells from a group. Calling this method should normally
+ not be necessary because after the construction or after a call to
+ UpdateShells() the requested list is empty.
+ @param eGroup
+ The group to clear. Shells in other groups are not modified.
+ */
+ void ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup);
+
+ /** Add a shell. When the specified shell has alreadt been requested
+ for another group then it is moved to this group.
+ @param eGroup
+ The group to which to add the shell.
+ @param nId
+ The id of the shell to add.
+ */
+ void AddShellId (sd::ToolBarManager::ToolBarGroup eGroup, sd::ShellId nId);
+
+ /** Releasing all shells means that the given ToolBarRules object is
+ informed that every shell mananged by the called ToolBarShellList is
+ about to be removed and that the associated framework tool bars can
+ be removed as well. The caller still has to call UpdateShells().
+ */
+ void ReleaseAllShells (ToolBarRules& rRules);
+
+ /** The requested list is made the current list by activating all
+ shells in the requested list and by deactivating the shells in the
+ current list that are not in the requested list.
+ @param pMainViewShell
+ The shells that are activated or deactivated are sub shells of
+ this view shell.
+ @param rManager
+ This ViewShellManager is used to activate or deactivate shells.
+ */
+ void UpdateShells (
+ const ::boost::shared_ptr<ViewShell>& rpMainViewShell,
+ const ::boost::shared_ptr<ViewShellManager>& rpManager);
+
+private:
+ class ShellDescriptor
+ {public:
+ ShellDescriptor (ShellId nId,sd::ToolBarManager::ToolBarGroup eGroup);
+ ShellId mnId;
+ sd::ToolBarManager::ToolBarGroup meGroup;
+ friend bool operator<(const ShellDescriptor& r1, const ShellDescriptor& r2)
+ { return r1.mnId < r2.mnId; }
+ };
+
+ /** The requested list of tool bar shells that will be active after the
+ next call to UpdateShells().
+ */
+ typedef ::std::set<ShellDescriptor> GroupedShellList;
+ GroupedShellList maNewList;
+
+ /** The list of tool bar shells that are currently on the shell stack.
+ Using a GroupedShellList is not strictly necessary but it makes
+ things easier and does not waste too much memory.
+ */
+ GroupedShellList maCurrentList;
+};
+
+
+
+
+/** This class concentrates the knowledge about when to show what tool bars
+ in one place.
+*/
+class ToolBarRules
+{
+public:
+ ToolBarRules (
+ const ::boost::shared_ptr<ToolBarManager>& rpToolBarManager,
+ const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager);
+
+ /** This method calls MainViewShellChanged() and SelectionHasChanged()
+ for the current main view shell and its view.
+ */
+ void Update (ViewShellBase& rBase);
+
+ /** Reset all tool bars in all groups and add tool bars and tool bar
+ shells to the TBG_PERMANENT group for the specified ViewShell type.
+ */
+ void MainViewShellChanged (ViewShell::ShellType nShellType);
+
+ /** Reset all tool bars in all groups and add tool bars and tool bar
+ shells to the TBG_PERMANENT group for the specified ViewShell.
+ */
+ void MainViewShellChanged (const ViewShell& rMainViewShell);
+
+ /** Reset all tool bars in the TBG_FUNCTION group and add tool bars and tool bar
+ shells to this group for the current selection.
+ */
+ void SelectionHasChanged (
+ const ::sd::ViewShell& rViewShell,
+ const SdrView& rView);
+
+ /** Add a tool bar for the specified tool bar shell.
+ */
+ void SubShellAdded (
+ ::sd::ToolBarManager::ToolBarGroup eGroup,
+ sd::ShellId nShellId);
+
+ /** Remove a tool bar for the specified tool bar shell.
+ */
+ void SubShellRemoved (
+ ::sd::ToolBarManager::ToolBarGroup eGroup,
+ sd::ShellId nShellId);
+
+private:
+ ::boost::shared_ptr<ToolBarManager> mpToolBarManager;
+ ::boost::shared_ptr<ViewShellManager> mpViewShellManager;
+};
+
+} // end of anonymous namespace
+
+
+
+
+namespace sd {
+
+//===== ToolBarManager::Implementation ========================================
+
+class ToolBarManager::Implementation
+{
+public:
+ /** This constructor takes three arguments even though the
+ ToolBarManager could be taken from the ViewShellBase. This is so to
+ state explicitly which information has to be present when this
+ constructor is called. The ViewShellBase may not have been fully
+ initialized at this point and must not be asked for this values.
+ */
+ Implementation (
+ ViewShellBase& rBase,
+ const ::boost::shared_ptr<sd::tools::EventMultiplexer>& rpMultiplexer,
+ const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager,
+ const ::boost::shared_ptr<ToolBarManager>& rpToolBarManager);
+ ~Implementation (void);
+
+ void SetValid (bool bValid);
+
+ void ResetToolBars (ToolBarGroup eGroup);
+ void ResetAllToolBars (void);
+ void AddToolBar (ToolBarGroup eGroup, const ::rtl::OUString& rsToolBarName);
+ void AddToolBarShell (ToolBarGroup eGroup, ShellId nToolBarId);
+ void RemoveToolBar (ToolBarGroup eGroup, const ::rtl::OUString& rsToolBarName);
+
+ /** Release all tool bar shells and the associated framework tool bars.
+ Typically called when the main view shell is being replaced by
+ another, all tool bar shells are released. In that process the
+ shells are destroyed anyway and whithout calling this method they
+ would still be referenced.
+ */
+ void ReleaseAllToolBarShells (void);
+
+ void ToolBarsDestroyed(void);
+
+ void RequestUpdate (void);
+
+ void PreUpdate (void);
+ void PostUpdate (void);
+ /** Tell the XLayoutManager about the tool bars that we would like to be
+ shown.
+ @param rpLayouterLock
+ This typically is the mpSynchronousLayouterLock that is used in
+ this method and that is either released at its end or assigned
+ to mpAsynchronousLock in order to be unlocked later.
+ */
+ void Update (::std::auto_ptr<LayouterLock> pLayouterLock);
+
+ class UpdateLockImplementation
+ {
+ public:
+ UpdateLockImplementation (Implementation& rImplementation)
+ : mrImplementation(rImplementation) { mrImplementation.LockUpdate(); }
+ ~UpdateLockImplementation (void) { mrImplementation.UnlockUpdate(); }
+ private:
+ Implementation& mrImplementation;
+ };
+
+ void LockViewShellManager (void);
+ void LockUpdate (void);
+ void UnlockUpdate (void);
+
+ ToolBarRules& GetToolBarRules (void);
+
+private:
+ const static ::rtl::OUString msToolBarResourcePrefix;
+
+ mutable ::osl::Mutex maMutex;
+ ViewShellBase& mrBase;
+ ::boost::shared_ptr<sd::tools::EventMultiplexer> mpEventMultiplexer;
+ bool mbIsValid;
+ ToolBarList maToolBarList;
+ ToolBarShellList maToolBarShellList;
+ Reference<frame::XLayoutManager> mxLayouter;
+ sal_Int32 mnLockCount;
+ bool mbPreUpdatePending;
+ bool mbPostUpdatePending;
+ /** The layouter locks manage the locking of the XLayoutManager. The
+ lock() and unlock() functions are not called directly because the
+ (final) unlocking is usually done asynchronously *after* the
+ list of requested toolbars is updated.
+ */
+ ::std::auto_ptr<LayouterLock> mpSynchronousLayouterLock;
+ ::std::auto_ptr<LayouterLock> mpAsynchronousLayouterLock;
+ ::std::auto_ptr<ViewShellManager::UpdateLock> mpViewShellManagerLock;
+ sal_uLong mnPendingUpdateCall;
+ sal_uLong mnPendingSetValidCall;
+ ToolBarRules maToolBarRules;
+
+ ::rtl::OUString GetToolBarResourceName (const ::rtl::OUString& rsBaseName) const;
+ bool CheckPlugInMode (const ::rtl::OUString& rsName) const;
+
+ DECL_LINK(UpdateCallback,bool*);
+ DECL_LINK(EventMultiplexerCallback, sd::tools::EventMultiplexerEvent*);
+ DECL_LINK(SetValidCallback,void*);
+};
+
+
+
+//===== ToolBarManager ========================================================
+
+const ::rtl::OUString ToolBarManager::msToolBar(OUSTRING("toolbar"));
+const ::rtl::OUString ToolBarManager::msOptionsToolBar(OUSTRING("optionsbar"));
+const ::rtl::OUString ToolBarManager::msCommonTaskToolBar(OUSTRING("commontaskbar"));
+const ::rtl::OUString ToolBarManager::msViewerToolBar(OUSTRING("viewerbar"));
+const ::rtl::OUString ToolBarManager::msSlideSorterToolBar(OUSTRING("slideviewtoolbar"));
+const ::rtl::OUString ToolBarManager::msSlideSorterObjectBar(OUSTRING("slideviewobjectbar"));
+const ::rtl::OUString ToolBarManager::msOutlineToolBar(OUSTRING("outlinetoolbar"));
+const ::rtl::OUString ToolBarManager::msMasterViewToolBar(OUSTRING("masterviewtoolbar"));
+const ::rtl::OUString ToolBarManager::msDrawingObjectToolBar(OUSTRING("drawingobjectbar"));
+const ::rtl::OUString ToolBarManager::msGluePointsToolBar(OUSTRING("gluepointsobjectbar"));
+const ::rtl::OUString ToolBarManager::msTextObjectBar(OUSTRING("textobjectbar"));
+const ::rtl::OUString ToolBarManager::msBezierObjectBar(OUSTRING("bezierobjectbar"));
+const ::rtl::OUString ToolBarManager::msGraphicObjectBar(OUSTRING("graphicobjectbar"));
+const ::rtl::OUString ToolBarManager::msMediaObjectBar(OUSTRING("mediaobjectbar"));
+const ::rtl::OUString ToolBarManager::msTableObjectBar(OUSTRING("tableobjectbar"));
+
+
+::boost::shared_ptr<ToolBarManager> ToolBarManager::Create (
+ ViewShellBase& rBase,
+ const ::boost::shared_ptr<sd::tools::EventMultiplexer>& rpMultiplexer,
+ const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager)
+{
+ ::boost::shared_ptr<ToolBarManager> pManager (new ToolBarManager());
+ pManager->mpImpl.reset(
+ new Implementation(rBase,rpMultiplexer,rpViewShellManager,pManager));
+ return pManager;
+}
+
+
+
+
+ToolBarManager::ToolBarManager (void)
+ : mpImpl()
+{
+}
+
+
+
+
+ToolBarManager::~ToolBarManager (void)
+{
+}
+
+
+
+
+void ToolBarManager::Shutdown (void)
+{
+ if (mpImpl.get() != NULL)
+ mpImpl.reset();
+}
+
+
+
+
+void ToolBarManager::ResetToolBars (ToolBarGroup eGroup)
+{
+ if (mpImpl.get() != NULL)
+ {
+ UpdateLock aLock (shared_from_this());
+ mpImpl->ResetToolBars(eGroup);
+ }
+}
+
+
+
+
+void ToolBarManager::ResetAllToolBars (void)
+{
+ if (mpImpl.get() != NULL)
+ {
+ UpdateLock aLock (shared_from_this());
+ mpImpl->ResetAllToolBars();
+ }
+}
+
+
+
+
+void ToolBarManager::AddToolBar (
+ ToolBarGroup eGroup,
+ const ::rtl::OUString& rsToolBarName)
+{
+ if (mpImpl.get() != NULL)
+ {
+ UpdateLock aLock (shared_from_this());
+ mpImpl->AddToolBar(eGroup,rsToolBarName);
+ }
+}
+
+
+
+
+void ToolBarManager::AddToolBarShell (
+ ToolBarGroup eGroup,
+ ShellId nToolBarId)
+{
+ if (mpImpl.get() != NULL)
+ {
+ UpdateLock aLock (shared_from_this());
+ mpImpl->AddToolBarShell(eGroup,nToolBarId);
+ }
+}
+
+
+
+
+void ToolBarManager::RemoveToolBar (
+ ToolBarGroup eGroup,
+ const ::rtl::OUString& rsToolBarName)
+{
+ if (mpImpl.get() != NULL)
+ {
+ UpdateLock aLock (shared_from_this());
+ mpImpl->RemoveToolBar(eGroup,rsToolBarName);
+ }
+}
+
+
+
+
+void ToolBarManager::SetToolBar (
+ ToolBarGroup eGroup,
+ const ::rtl::OUString& rsToolBarName)
+{
+ if (mpImpl.get() != NULL)
+ {
+ UpdateLock aLock (shared_from_this());
+ mpImpl->ResetToolBars(eGroup);
+ mpImpl->AddToolBar(eGroup,rsToolBarName);
+ }
+}
+
+
+
+
+void ToolBarManager::SetToolBarShell (
+ ToolBarGroup eGroup,
+ ShellId nToolBarId)
+{
+ if (mpImpl.get() != NULL)
+ {
+ UpdateLock aLock (shared_from_this());
+ mpImpl->ResetToolBars(eGroup);
+ mpImpl->AddToolBarShell(eGroup,nToolBarId);
+ }
+}
+
+
+
+
+void ToolBarManager::PreUpdate (void)
+{
+ if (mpImpl.get()!=NULL)
+ mpImpl->PreUpdate();
+}
+
+
+
+
+void ToolBarManager::RequestUpdate (void)
+{
+ if (mpImpl.get()!=NULL)
+ mpImpl->RequestUpdate();
+}
+
+
+
+
+void ToolBarManager::LockViewShellManager (void)
+{
+ if (mpImpl.get() != NULL)
+ mpImpl->LockViewShellManager();
+}
+
+
+
+
+void ToolBarManager::LockUpdate (void)
+{
+ if (mpImpl.get()!=NULL)
+ mpImpl->LockUpdate();
+}
+
+
+
+
+void ToolBarManager::UnlockUpdate (void)
+{
+ if (mpImpl.get()!=NULL)
+ mpImpl->UnlockUpdate();
+}
+
+
+
+
+void ToolBarManager::MainViewShellChanged (ViewShell::ShellType nShellType)
+{
+ if (mpImpl.get() != NULL)
+ {
+ mpImpl->ReleaseAllToolBarShells();
+ mpImpl->GetToolBarRules().MainViewShellChanged(nShellType);
+ }
+}
+
+
+
+
+void ToolBarManager::MainViewShellChanged (const ViewShell& rMainViewShell)
+{
+ if (mpImpl.get() != NULL)
+ {
+ mpImpl->ReleaseAllToolBarShells();
+ mpImpl->GetToolBarRules().MainViewShellChanged(rMainViewShell);
+ }
+}
+
+
+
+
+void ToolBarManager::SelectionHasChanged (
+ const ViewShell& rViewShell,
+ const SdrView& rView)
+{
+ if (mpImpl.get() != NULL)
+ mpImpl->GetToolBarRules().SelectionHasChanged(rViewShell,rView);
+}
+
+
+void ToolBarManager::ToolBarsDestroyed(void)
+{
+ if (mpImpl.get() != NULL)
+ mpImpl->ToolBarsDestroyed();
+}
+
+
+//===== ToolBarManager::Implementation =======================================
+
+const ::rtl::OUString ToolBarManager::Implementation::msToolBarResourcePrefix(
+ OUSTRING("private:resource/toolbar/"));
+
+ToolBarManager::Implementation::Implementation (
+ ViewShellBase& rBase,
+ const ::boost::shared_ptr<sd::tools::EventMultiplexer>& rpMultiplexer,
+ const ::boost::shared_ptr<ViewShellManager>& rpViewShellManager,
+ const ::boost::shared_ptr<ToolBarManager>& rpToolBarManager)
+ : maMutex(),
+ mrBase(rBase),
+ mpEventMultiplexer(rpMultiplexer),
+ mbIsValid(false),
+ maToolBarList(),
+ maToolBarShellList(),
+ mxLayouter(NULL),
+ mnLockCount(0),
+ mbPreUpdatePending(false),
+ mbPostUpdatePending(false),
+ mpSynchronousLayouterLock(),
+ mpAsynchronousLayouterLock(),
+ mpViewShellManagerLock(),
+ mnPendingUpdateCall(0),
+ mnPendingSetValidCall(0),
+ maToolBarRules(rpToolBarManager,rpViewShellManager)
+{
+ Link aLink (LINK(this,ToolBarManager::Implementation,EventMultiplexerCallback));
+ mpEventMultiplexer->AddEventListener(
+ aLink,
+ tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED
+ | tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED
+ | tools::EventMultiplexerEvent::EID_PANE_MANAGER_DYING);
+}
+
+
+
+/** The order of statements is important.
+ First unregister listeners, which may post user events.
+ Then remove pending user events.
+*/
+ToolBarManager::Implementation::~Implementation (void)
+{
+ // Unregister at broadcasters.
+ Link aLink (LINK(this,ToolBarManager::Implementation,EventMultiplexerCallback));
+ mpEventMultiplexer->RemoveEventListener(aLink);
+
+ // Abort pending user calls.
+ if (mnPendingUpdateCall != 0)
+ Application::RemoveUserEvent(mnPendingUpdateCall);
+ if (mnPendingSetValidCall != 0)
+ Application::RemoveUserEvent(mnPendingSetValidCall);
+}
+
+
+void ToolBarManager::Implementation::ToolBarsDestroyed(void)
+{
+ maToolBarList.MarkAllToolBarsAsNotActive();
+}
+
+
+void ToolBarManager::Implementation::SetValid (bool bValid)
+{
+ ::osl::MutexGuard aGuard(maMutex);
+
+ if (mbIsValid != bValid)
+ {
+ UpdateLockImplementation aUpdateLock (*this);
+
+ mbIsValid = bValid;
+ if (mbIsValid)
+ {
+ Reference<frame::XFrame> xFrame;
+ if (mrBase.GetViewFrame() != NULL)
+ xFrame = mrBase.GetViewFrame()->GetFrame().GetFrameInterface();
+ try
+ {
+ Reference<beans::XPropertySet> xFrameProperties (xFrame, UNO_QUERY_THROW);
+ Any aValue (xFrameProperties->getPropertyValue(OUSTRING("LayoutManager")));
+ aValue >>= mxLayouter;
+ }
+ catch (RuntimeException aException)
+ {
+ }
+
+ GetToolBarRules().Update(mrBase);
+ }
+ else
+ {
+ ResetAllToolBars();
+ mxLayouter = NULL;
+ }
+ }
+}
+
+
+
+
+void ToolBarManager::Implementation::ResetToolBars (ToolBarGroup eGroup)
+{
+ ::osl::MutexGuard aGuard(maMutex);
+
+ maToolBarList.ClearGroup(eGroup);
+ maToolBarShellList.ClearGroup(eGroup);
+
+ mbPreUpdatePending = true;
+}
+
+
+
+
+void ToolBarManager::Implementation::ResetAllToolBars (void)
+{
+#ifdef VERBOSE
+ OSL_TRACE("resetting all tool bars\n");
+#endif
+ for (int i=TBG__FIRST; i<=TBG__LAST; ++i)
+ ResetToolBars((ToolBarGroup)i);
+}
+
+
+
+
+void ToolBarManager::Implementation::AddToolBar (
+ ToolBarGroup eGroup,
+ const ::rtl::OUString& rsToolBarName)
+{
+ ::osl::MutexGuard aGuard(maMutex);
+
+ if (CheckPlugInMode(rsToolBarName))
+ {
+ maToolBarList.AddToolBar(eGroup,rsToolBarName);
+
+ mbPostUpdatePending = true;
+ if (mnLockCount == 0)
+ PostUpdate();
+ }
+}
+
+
+
+
+void ToolBarManager::Implementation::RemoveToolBar (
+ ToolBarGroup eGroup,
+ const ::rtl::OUString& rsToolBarName)
+{
+ ::osl::MutexGuard aGuard(maMutex);
+
+ if (maToolBarList.RemoveToolBar(eGroup,rsToolBarName))
+ {
+ mbPreUpdatePending = true;
+ if (mnLockCount == 0)
+ PreUpdate();
+ }
+}
+
+
+
+
+void ToolBarManager::Implementation::AddToolBarShell (
+ ToolBarGroup eGroup,
+ ShellId nToolBarId)
+{
+ ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
+ if (pMainViewShell != NULL)
+ {
+ maToolBarShellList.AddShellId(eGroup,nToolBarId);
+ GetToolBarRules().SubShellAdded(eGroup, nToolBarId);
+ }
+}
+
+
+
+
+void ToolBarManager::Implementation::ReleaseAllToolBarShells (void)
+{
+ maToolBarShellList.ReleaseAllShells(GetToolBarRules());
+ maToolBarShellList.UpdateShells(mrBase.GetMainViewShell(), mrBase.GetViewShellManager());
+}
+
+
+
+
+void ToolBarManager::Implementation::RequestUpdate (void)
+{
+ if (mnPendingUpdateCall == 0)
+ {
+ mnPendingUpdateCall = Application::PostUserEvent(
+ LINK(this,ToolBarManager::Implementation,UpdateCallback));
+ }
+}
+
+
+
+
+void ToolBarManager::Implementation::PreUpdate (void)
+{
+ ::osl::MutexGuard aGuard(maMutex);
+
+ if (mbIsValid
+ && mbPreUpdatePending
+ && mxLayouter.is())
+ {
+ mbPreUpdatePending = false;
+
+#ifdef VERBOSE
+ OSL_TRACE("ToolBarManager::PreUpdate [");
+#endif
+
+ // Get the list of tool bars that are not used anymore and are to be
+ // deactivated.
+ NameList aToolBars;
+ maToolBarList.GetToolBarsToDeactivate(aToolBars);
+
+ // Turn off the tool bars.
+ NameList::const_iterator iToolBar;
+ for (iToolBar=aToolBars.begin(); iToolBar!=aToolBars.end(); ++iToolBar)
+ {
+ ::rtl::OUString sFullName (GetToolBarResourceName(*iToolBar));
+#ifdef VERBOSE
+ OSL_TRACE(" turning off tool bar %s",
+ ::rtl::OUStringToOString(sFullName, RTL_TEXTENCODING_UTF8).getStr());
+#endif
+ mxLayouter->destroyElement(sFullName);
+ maToolBarList.MarkToolBarAsNotActive(*iToolBar);
+ }
+
+#ifdef VERBOSE
+ OSL_TRACE("ToolBarManager::PreUpdate ]\n");
+#endif
+ }
+}
+
+
+
+
+void ToolBarManager::Implementation::PostUpdate (void)
+{
+ ::osl::MutexGuard aGuard(maMutex);
+
+ if (mbIsValid
+ && mbPostUpdatePending
+ && mxLayouter.is())
+ {
+ mbPostUpdatePending = false;
+
+ // Create the list of requested tool bars.
+ NameList aToolBars;
+ maToolBarList.GetToolBarsToActivate(aToolBars);
+
+#ifdef VERBOSE
+ OSL_TRACE("ToolBarManager::PostUpdate [");
+#endif
+
+ // Turn on the tool bars that are visible in the new context.
+ NameList::const_iterator iToolBar;
+ for (iToolBar=aToolBars.begin(); iToolBar!=aToolBars.end(); ++iToolBar)
+ {
+ ::rtl::OUString sFullName (GetToolBarResourceName(*iToolBar));
+#ifdef VERBOSE
+ OSL_TRACE(" turning on tool bar %s",
+ ::rtl::OUStringToOString(sFullName, RTL_TEXTENCODING_UTF8).getStr());
+#endif
+ mxLayouter->requestElement(sFullName);
+ maToolBarList.MarkToolBarAsActive(*iToolBar);
+ }
+
+#ifdef VERBOSE
+ OSL_TRACE("ToolBarManager::PostUpdate ]\n");
+#endif
+ }
+}
+
+
+
+
+void ToolBarManager::Implementation::LockViewShellManager (void)
+{
+ if (mpViewShellManagerLock.get() == NULL)
+ mpViewShellManagerLock.reset(
+ new ViewShellManager::UpdateLock(mrBase.GetViewShellManager()));
+}
+
+
+
+
+void ToolBarManager::Implementation::LockUpdate (void)
+{
+#ifdef VERBOSE
+ OSL_TRACE("LockUpdate %d\n", mnLockCount);
+#endif
+ ::osl::MutexGuard aGuard(maMutex);
+
+ DBG_ASSERT(mnLockCount<100, "ToolBarManager lock count unusually high");
+ if (mnLockCount == 0)
+ {
+ OSL_ASSERT(mpSynchronousLayouterLock.get()==NULL);
+
+ mpSynchronousLayouterLock.reset(new LayouterLock(mxLayouter));
+ }
+ ++mnLockCount;
+}
+
+
+
+
+void ToolBarManager::Implementation::UnlockUpdate (void)
+{
+#ifdef VERBOSE
+ OSL_TRACE("UnlockUpdate %d\n", mnLockCount);
+#endif
+ ::osl::MutexGuard aGuard(maMutex);
+
+ OSL_ASSERT(mnLockCount>0);
+ --mnLockCount;
+ if (mnLockCount == 0)
+ {
+ Update(mpSynchronousLayouterLock);
+ }
+}
+
+
+
+
+void ToolBarManager::Implementation::Update (
+ ::std::auto_ptr<LayouterLock> pLocalLayouterLock)
+{
+ // When the lock is released and there are pending changes to the set of
+ // tool bars then update this set now.
+ if (mnLockCount == 0)
+ {
+ // During ceation of ViewShellBase we may have the situation that
+ // the controller has already been created and attached to the frame
+ // but that the ToolBarManager has not yet completed its
+ // initialization (by initializing the mxLayouter member.) We do
+ // this here so that we do not have to wait for the next Update()
+ // call to show the tool bars.
+ if (mnPendingSetValidCall != 0)
+ {
+ Application::RemoveUserEvent(mnPendingSetValidCall);
+ mnPendingSetValidCall = 0;
+ SetValid(true);
+ }
+
+ if (mbIsValid && mxLayouter.is() && (mbPreUpdatePending || mbPostUpdatePending))
+ {
+ // 1) Release UNO tool bars that are not longer used. Do this
+ // now so that they are not updated when the SFX shell stack is
+ // modified.
+ if (mbPreUpdatePending)
+ PreUpdate();
+
+ // 2) Update the requested shells that represent tool bar
+ // functionality. Those that are not used anymore are
+ // deactivated now. Those that are missing are activated in the
+ // next step together with the view shells.
+ if (mpViewShellManagerLock.get() == NULL)
+ mpViewShellManagerLock.reset(
+ new ViewShellManager::UpdateLock(mrBase.GetViewShellManager()));
+ maToolBarShellList.UpdateShells(
+ mrBase.GetMainViewShell(),
+ mrBase.GetViewShellManager());
+
+ // 3) Unlock the ViewShellManager::UpdateLock. This updates the
+ // shell stack. We have to be carfull here. The deletion of
+ // the lock may end in a synchronous call to LockUpdate(). When
+ // at this time the lock has been deleted but the auto_ptr has
+ // not yet been reset then the lock is deleted a second time.
+ ViewShellManager::UpdateLock* pLock = mpViewShellManagerLock.release();
+ delete pLock;
+
+ // 4) Make the UNO tool bars visible. The outstanding call to
+ // PostUpdate() is done via PostUserEvent() so that it is
+ // guaranteed to be executed when the SFX shell stack has been
+ // updated (under the assumption that our lock to the
+ // ViewShellManager was the only one open. If that is not the
+ // case then all should still be well but not as fast.)
+ //
+ // Note that the lock count may have been increased since
+ // entering this method. In that case one of the next
+ // UnlockUpdate() calls will post the UpdateCallback.
+ if (mnPendingUpdateCall==0 && mnLockCount==0)
+ {
+ mpAsynchronousLayouterLock = pLocalLayouterLock;
+ mnPendingUpdateCall = Application::PostUserEvent(
+ LINK(this,ToolBarManager::Implementation,UpdateCallback));
+ }
+ }
+ else
+ {
+ mpViewShellManagerLock.reset();
+ pLocalLayouterLock.reset();
+ }
+ }
+}
+
+
+
+
+ToolBarRules& ToolBarManager::Implementation::GetToolBarRules (void)
+{
+ return maToolBarRules;
+}
+
+
+
+
+IMPL_LINK(ToolBarManager::Implementation,UpdateCallback,bool*,EMPTYARG)
+{
+ mnPendingUpdateCall = 0;
+ if (mnLockCount == 0)
+ {
+ if (mbPreUpdatePending)
+ PreUpdate();
+ if (mbPostUpdatePending)
+ PostUpdate();
+ if (mbIsValid && mxLayouter.is())
+ mpAsynchronousLayouterLock.reset();
+ }
+ return 0;
+}
+
+
+
+
+IMPL_LINK(ToolBarManager::Implementation,EventMultiplexerCallback,
+ sd::tools::EventMultiplexerEvent*,pEvent)
+{
+ if (pEvent != NULL)
+ {
+ switch (pEvent->meEventId)
+ {
+ case tools::EventMultiplexerEvent::EID_CONTROLLER_ATTACHED:
+ if (mnPendingSetValidCall == 0)
+ mnPendingSetValidCall
+ = Application::PostUserEvent(LINK(this,Implementation,SetValidCallback));
+ break;
+
+ case tools::EventMultiplexerEvent::EID_CONTROLLER_DETACHED:
+ SetValid(false);
+ break;
+
+ case tools::EventMultiplexerEvent::EID_PANE_MANAGER_DYING:
+ SetValid(false);
+ break;
+ }
+ }
+ return 0;
+}
+
+
+
+
+IMPL_LINK(ToolBarManager::Implementation, SetValidCallback,void*,EMPTYARG)
+{
+ mnPendingSetValidCall = 0;
+ SetValid(true);
+ return 0;
+}
+
+
+
+
+
+::rtl::OUString ToolBarManager::Implementation::GetToolBarResourceName (
+ const ::rtl::OUString& rsBaseName) const
+{
+ ::rtl::OUString sToolBarName (msToolBarResourcePrefix);
+ sToolBarName += rsBaseName;
+ return sToolBarName;
+}
+
+
+
+
+bool ToolBarManager::Implementation::CheckPlugInMode (const ::rtl::OUString& rsName) const
+{
+ bool bValid (false);
+
+ // Determine the plug in mode.
+ bool bIsPlugInMode (false);
+ do
+ {
+ SfxObjectShell* pObjectShell = mrBase.GetObjectShell();
+ if (pObjectShell == NULL)
+ break;
+
+ SfxMedium* pMedium = pObjectShell->GetMedium();
+ if (pMedium == NULL)
+ break;
+
+ SFX_ITEMSET_ARG(pMedium->GetItemSet(),pViewOnlyItem,SfxBoolItem,SID_VIEWONLY,sal_False);
+ if (pViewOnlyItem == NULL)
+ break;
+
+ bIsPlugInMode = pViewOnlyItem->GetValue();
+ }
+ while (false);
+
+ if (rsName.equals(msViewerToolBar))
+ bValid = bIsPlugInMode;
+ else
+ bValid = ! bIsPlugInMode;
+
+ return bValid;
+}
+
+
+
+
+} // end of namespace sd
+
+
+
+
+namespace {
+
+using namespace ::sd;
+
+//===== LayouterLock ==========================================================
+
+LayouterLock::LayouterLock (const Reference<frame::XLayoutManager>& rxLayouter)
+ : mxLayouter(rxLayouter)
+{
+#ifdef VERBOSE
+ OSL_TRACE("LayouterLock %d", mxLayouter.is() ? 1 :0);
+#endif
+ if (mxLayouter.is())
+ mxLayouter->lock();
+}
+
+
+
+
+LayouterLock::~LayouterLock (void)
+{
+#ifdef VERBOSE
+ OSL_TRACE("~LayouterLock %d", mxLayouter.is() ? 1 :0);
+#endif
+ if (mxLayouter.is())
+ mxLayouter->unlock();
+}
+
+
+
+
+//===== ToolBarRules ==========================================================
+
+ToolBarRules::ToolBarRules (
+ const ::boost::shared_ptr<sd::ToolBarManager>& rpToolBarManager,
+ const ::boost::shared_ptr<sd::ViewShellManager>& rpViewShellManager)
+ : mpToolBarManager(rpToolBarManager),
+ mpViewShellManager(rpViewShellManager)
+{
+}
+
+
+
+
+void ToolBarRules::Update (ViewShellBase& rBase)
+{
+ ViewShell* pMainViewShell = rBase.GetMainViewShell().get();
+ if (pMainViewShell != NULL)
+ {
+ MainViewShellChanged(pMainViewShell->GetShellType());
+ if (pMainViewShell->GetView())
+ SelectionHasChanged (*pMainViewShell, *pMainViewShell->GetView());
+ }
+ else
+ MainViewShellChanged(ViewShell::ST_NONE);
+}
+
+
+
+
+void ToolBarRules::MainViewShellChanged (ViewShell::ShellType nShellType)
+{
+ ::sd::ToolBarManager::UpdateLock aToolBarManagerLock (mpToolBarManager);
+ ::sd::ViewShellManager::UpdateLock aViewShellManagerLock (mpViewShellManager);
+
+ mpToolBarManager->ResetAllToolBars();
+
+ switch(nShellType)
+ {
+ case ::sd::ViewShell::ST_IMPRESS:
+ case ::sd::ViewShell::ST_NOTES:
+ case ::sd::ViewShell::ST_HANDOUT:
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msToolBar);
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msOptionsToolBar);
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msCommonTaskToolBar);
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msViewerToolBar);
+ break;
+
+ case ::sd::ViewShell::ST_DRAW:
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msToolBar);
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msOptionsToolBar);
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msViewerToolBar);
+ break;
+
+ case ViewShell::ST_OUTLINE:
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msOutlineToolBar);
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msViewerToolBar);
+ mpToolBarManager->AddToolBarShell(
+ ToolBarManager::TBG_PERMANENT, RID_DRAW_TEXT_TOOLBOX);
+ break;
+
+ case ViewShell::ST_SLIDE_SORTER:
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msViewerToolBar);
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msSlideSorterToolBar);
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_PERMANENT,
+ ToolBarManager::msSlideSorterObjectBar);
+ break;
+
+ case ViewShell::ST_NONE:
+ case ViewShell::ST_PRESENTATION:
+ case ViewShell::ST_TASK_PANE:
+ default:
+ break;
+ }
+}
+
+
+
+
+void ToolBarRules::MainViewShellChanged (const ViewShell& rMainViewShell)
+{
+ ::sd::ToolBarManager::UpdateLock aToolBarManagerLock (mpToolBarManager);
+ ::sd::ViewShellManager::UpdateLock aViewShellManagerLock (mpViewShellManager);
+
+ MainViewShellChanged(rMainViewShell.GetShellType());
+ switch(rMainViewShell.GetShellType())
+ {
+ case ::sd::ViewShell::ST_IMPRESS:
+ case ::sd::ViewShell::ST_DRAW:
+ case ::sd::ViewShell::ST_NOTES:
+ {
+ const DrawViewShell* pDrawViewShell
+ = dynamic_cast<const DrawViewShell*>(&rMainViewShell);
+ if (pDrawViewShell != NULL)
+ if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
+ mpToolBarManager->AddToolBar(
+ ToolBarManager::TBG_MASTER_MODE,
+ ToolBarManager::msMasterViewToolBar);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
+
+
+void ToolBarRules::SelectionHasChanged (
+ const ::sd::ViewShell& rViewShell,
+ const SdrView& rView)
+{
+ ::sd::ToolBarManager::UpdateLock aLock (mpToolBarManager);
+ mpToolBarManager->LockViewShellManager();
+ bool bTextEdit = rView.IsTextEdit();
+
+ mpToolBarManager->ResetToolBars(ToolBarManager::TBG_FUNCTION);
+
+ switch (rView.GetContext())
+ {
+ case SDRCONTEXT_GRAPHIC:
+ if( !bTextEdit )
+ mpToolBarManager->SetToolBarShell(ToolBarManager::TBG_FUNCTION, RID_DRAW_GRAF_TOOLBOX);
+ break;
+
+ case SDRCONTEXT_MEDIA:
+ if( !bTextEdit )
+ mpToolBarManager->SetToolBarShell(ToolBarManager::TBG_FUNCTION, RID_DRAW_MEDIA_TOOLBOX);
+ break;
+
+ case SDRCONTEXT_TABLE:
+ mpToolBarManager->SetToolBarShell(ToolBarManager::TBG_FUNCTION, RID_DRAW_TABLE_TOOLBOX);
+ bTextEdit = true;
+ break;
+
+ case SDRCONTEXT_STANDARD:
+ default:
+ if( !bTextEdit )
+ {
+ switch(rViewShell.GetShellType())
+ {
+ case ::sd::ViewShell::ST_IMPRESS:
+ case ::sd::ViewShell::ST_DRAW:
+ case ::sd::ViewShell::ST_NOTES:
+ case ::sd::ViewShell::ST_HANDOUT:
+ mpToolBarManager->SetToolBar(
+ ToolBarManager::TBG_FUNCTION,
+ ToolBarManager::msDrawingObjectToolBar);
+ break;
+ default:
+ break;
+ }
+ break;
+ }
+ }
+
+ if( bTextEdit )
+ mpToolBarManager->AddToolBarShell(ToolBarManager::TBG_FUNCTION, RID_DRAW_TEXT_TOOLBOX);
+
+ SdrView* pView = &const_cast<SdrView&>(rView);
+ // Check if the extrusion tool bar and the fontwork tool bar have to
+ // be activated.
+ if (svx::checkForSelectedCustomShapes(pView, true /* bOnlyExtruded */ ))
+ mpToolBarManager->AddToolBarShell(ToolBarManager::TBG_FUNCTION, RID_SVX_EXTRUSION_BAR);
+ sal_uInt32 nCheckStatus = 0;
+ if (svx::checkForSelectedFontWork(pView, nCheckStatus))
+ mpToolBarManager->AddToolBarShell(ToolBarManager::TBG_FUNCTION, RID_SVX_FONTWORK_BAR);
+
+ // Switch on additional context-sensitive tool bars.
+ if (rView.GetContext() == SDRCONTEXT_POINTEDIT)
+ mpToolBarManager->AddToolBarShell(ToolBarManager::TBG_FUNCTION, RID_BEZIER_TOOLBOX);
+}
+
+
+
+
+void ToolBarRules::SubShellAdded (
+ ::sd::ToolBarManager::ToolBarGroup eGroup,
+ sd::ShellId nShellId)
+{
+ // For some tool bar shells (those defined in sd) we have to add the
+ // actual tool bar here.
+ switch (nShellId)
+ {
+ case RID_DRAW_GRAF_TOOLBOX:
+ mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msGraphicObjectBar);
+ break;
+
+ case RID_DRAW_MEDIA_TOOLBOX:
+ mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msMediaObjectBar);
+ break;
+
+ case RID_DRAW_TEXT_TOOLBOX:
+ mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msTextObjectBar);
+ break;
+
+ case RID_BEZIER_TOOLBOX:
+ mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msBezierObjectBar);
+ break;
+
+ case RID_DRAW_TABLE_TOOLBOX:
+ mpToolBarManager->AddToolBar(eGroup, ToolBarManager::msTableObjectBar);
+ break;
+ }
+}
+
+
+
+
+void ToolBarRules::SubShellRemoved (
+ ::sd::ToolBarManager::ToolBarGroup eGroup,
+ sd::ShellId nShellId)
+{
+ // For some tool bar shells (those defined in sd) we have to add the
+ // actual tool bar here.
+ switch (nShellId)
+ {
+ case RID_DRAW_GRAF_TOOLBOX:
+ mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msGraphicObjectBar);
+ break;
+
+ case RID_DRAW_MEDIA_TOOLBOX:
+ mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msMediaObjectBar);
+ break;
+
+ case RID_DRAW_TEXT_TOOLBOX:
+ mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msTextObjectBar);
+ break;
+
+ case RID_BEZIER_TOOLBOX:
+ mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msBezierObjectBar);
+ break;
+
+ case RID_DRAW_TABLE_TOOLBOX:
+ mpToolBarManager->RemoveToolBar(eGroup, ToolBarManager::msTableObjectBar);
+ break;
+ }
+}
+
+
+
+
+//===== ToolBarList ===========================================================
+
+ToolBarList::ToolBarList (void)
+ : maGroups(),
+ maActiveToolBars()
+{
+}
+
+
+
+
+void ToolBarList::ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup)
+{
+ Groups::iterator iGroup (maGroups.find(eGroup));
+ if (iGroup != maGroups.end())
+ {
+ if ( ! iGroup->second.empty())
+ {
+ iGroup->second.clear();
+ }
+ }
+}
+
+
+
+
+void ToolBarList::AddToolBar (
+ sd::ToolBarManager::ToolBarGroup eGroup,
+ const ::rtl::OUString& rsName)
+{
+ Groups::iterator iGroup (maGroups.find(eGroup));
+ if (iGroup == maGroups.end())
+ iGroup = maGroups.insert(Groups::value_type(eGroup,NameList())).first;
+
+ if (iGroup != maGroups.end())
+ {
+ NameList::const_iterator iBar (
+ ::std::find(iGroup->second.begin(),iGroup->second.end(),rsName));
+ if (iBar == iGroup->second.end())
+ {
+ iGroup->second.push_back(rsName);
+ }
+ }
+}
+
+
+
+
+bool ToolBarList::RemoveToolBar (
+ sd::ToolBarManager::ToolBarGroup eGroup,
+ const ::rtl::OUString& rsName)
+{
+ Groups::iterator iGroup (maGroups.find(eGroup));
+ if (iGroup != maGroups.end())
+ {
+ NameList::iterator iBar (
+ ::std::find(iGroup->second.begin(),iGroup->second.end(),rsName));
+ if (iBar != iGroup->second.end())
+ {
+ iGroup->second.erase(iBar);
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
+
+void ToolBarList::MakeRequestedToolBarList (NameList& rRequestedToolBars) const
+{
+ for (int i=sd::ToolBarManager::TBG__FIRST; i<=sd::ToolBarManager::TBG__LAST; ++i)
+ {
+ ::sd::ToolBarManager::ToolBarGroup eGroup = (::sd::ToolBarManager::ToolBarGroup)i;
+ Groups::const_iterator iGroup (maGroups.find(eGroup));
+ if (iGroup != maGroups.end())
+ ::std::copy(
+ iGroup->second.begin(),
+ iGroup->second.end(),
+ ::std::inserter(rRequestedToolBars,rRequestedToolBars.end()));
+ }
+}
+
+
+
+
+void ToolBarList::GetToolBarsToActivate (NameList& rToolBars) const
+{
+ NameList aRequestedToolBars;
+ MakeRequestedToolBarList(aRequestedToolBars);
+
+ NameList::const_iterator iToolBar;
+ for (iToolBar=aRequestedToolBars.begin(); iToolBar!=aRequestedToolBars.end(); ++iToolBar)
+ {
+ if (::std::find(maActiveToolBars.begin(),maActiveToolBars.end(),*iToolBar)
+ == maActiveToolBars.end())
+ {
+ rToolBars.push_back(*iToolBar);
+ }
+ }
+}
+
+
+
+
+void ToolBarList::GetToolBarsToDeactivate (NameList& rToolBars) const
+{
+ NameList aRequestedToolBars;
+ MakeRequestedToolBarList(aRequestedToolBars);
+
+ NameList::const_iterator iToolBar;
+ for (iToolBar=maActiveToolBars.begin(); iToolBar!=maActiveToolBars.end(); ++iToolBar)
+ {
+ if (::std::find(aRequestedToolBars.begin(),aRequestedToolBars.end(),*iToolBar)
+ == aRequestedToolBars.end())
+ {
+ rToolBars.push_back(*iToolBar);
+ }
+ }
+}
+
+
+
+
+void ToolBarList::MarkToolBarAsActive (const ::rtl::OUString& rsName)
+{
+ maActiveToolBars.push_back(rsName);
+}
+
+
+
+
+void ToolBarList::MarkToolBarAsNotActive (const ::rtl::OUString& rsName)
+{
+ maActiveToolBars.erase(
+ ::std::find(maActiveToolBars.begin(),maActiveToolBars.end(), rsName));
+}
+
+
+
+
+void ToolBarList::MarkAllToolBarsAsNotActive (void)
+{
+ maActiveToolBars.clear();
+}
+
+
+
+
+//===== ToolBarShellList ======================================================
+
+ToolBarShellList::ShellDescriptor::ShellDescriptor (
+ ShellId nId,
+ sd::ToolBarManager::ToolBarGroup eGroup)
+ : mnId(nId),
+ meGroup(eGroup)
+{
+}
+
+
+
+
+ToolBarShellList::ToolBarShellList (void)
+: maNewList()
+, maCurrentList()
+{
+}
+
+
+
+
+void ToolBarShellList::ClearGroup (sd::ToolBarManager::ToolBarGroup eGroup)
+{
+ // In every loop we erase the first member of the specified group.
+ // Because that invalidates the iterator another loop is started after
+ // that. The loop is left only when no member of the group is found and
+ // no element is erased
+ bool bLoop;
+ do
+ {
+ bLoop = false;
+
+ GroupedShellList::iterator iDescriptor;
+ for (iDescriptor=maNewList.begin(); iDescriptor!=maNewList.end(); ++iDescriptor)
+ if (iDescriptor->meGroup == eGroup)
+ {
+ maNewList.erase(iDescriptor);
+ // Erasing the descriptor invalidated the iterator so we
+ // have to exit the for loop and start anew to search for
+ // further elements of the group.
+ bLoop = true;
+ break;
+ }
+ }
+ while (bLoop);
+}
+
+
+
+
+void ToolBarShellList::AddShellId (sd::ToolBarManager::ToolBarGroup eGroup, sd::ShellId nId)
+{
+ // Make sure that the shell is not added twice (and possibly in
+ // different groups.)
+ ShellDescriptor aDescriptor (nId,eGroup);
+ GroupedShellList::iterator iDescriptor (maNewList.find(aDescriptor));
+ if (iDescriptor != maNewList.end())
+ {
+ // The shell is already requested.
+ if (iDescriptor->meGroup != eGroup)
+ {
+ // It is now being requested for another group.
+ // (Is this an error?)
+ // Move it to that group.
+ maNewList.erase(iDescriptor);
+ maNewList.insert(aDescriptor);
+ }
+ // else nothing to do.
+ }
+ else
+ maNewList.insert(aDescriptor);
+}
+
+
+
+
+void ToolBarShellList::ReleaseAllShells (ToolBarRules& rRules)
+{
+ // Release the currently active tool bars.
+ GroupedShellList aList (maCurrentList);
+ GroupedShellList::iterator iDescriptor;
+ for (iDescriptor=aList.begin(); iDescriptor!=aList.end(); ++iDescriptor)
+ {
+ rRules.SubShellRemoved(iDescriptor->meGroup, iDescriptor->mnId);
+ }
+
+ // Clear the list of requested tool bars.
+ maNewList.clear();
+}
+
+
+
+
+void ToolBarShellList::UpdateShells (
+ const ::boost::shared_ptr<ViewShell>& rpMainViewShell,
+ const ::boost::shared_ptr<ViewShellManager>& rpManager)
+{
+ if (rpMainViewShell.get() != NULL)
+ {
+ GroupedShellList aList;
+
+ // Deactivate shells that are in maCurrentList, but not in
+ // maNewList.
+ ::std::set_difference(maCurrentList.begin(), maCurrentList.end(),
+ maNewList.begin(), maNewList.end(),
+ std::insert_iterator<GroupedShellList>(aList,aList.begin()));
+ for (GroupedShellList::iterator iShell=aList.begin(); iShell!=aList.end(); ++iShell)
+ {
+#ifdef VERBOSE
+ OSL_TRACE("deactivating tool bar shell %d\n", iShell->mnId);
+#endif
+ rpManager->DeactivateSubShell(*rpMainViewShell, iShell->mnId);
+ }
+
+ // Activate shells that are in maNewList, but not in
+ // maCurrentList.
+ aList.clear();
+ ::std::set_difference(maNewList.begin(), maNewList.end(),
+ maCurrentList.begin(), maCurrentList.end(),
+ std::insert_iterator<GroupedShellList>(aList,aList.begin()));
+ for (GroupedShellList::iterator iShell=aList.begin(); iShell!=aList.end(); ++iShell)
+ {
+#ifdef VERBOSE
+ OSL_TRACE("activating tool bar shell %d\n", iShell->mnId);
+#endif
+ rpManager->ActivateSubShell(*rpMainViewShell, iShell->mnId);
+ }
+
+ // The maNewList now refelects the current state and thus is made
+ // maCurrentList.
+ maCurrentList = maNewList;
+ }
+}
+
+
+
+
+} // end of anonymous namespace
diff --git a/sd/source/ui/view/UpdateLockManager.cxx b/sd/source/ui/view/UpdateLockManager.cxx
new file mode 100644
index 000000000000..f373042f627b
--- /dev/null
+++ b/sd/source/ui/view/UpdateLockManager.cxx
@@ -0,0 +1,429 @@
+/*************************************************************************
+ *
+ * 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 "UpdateLockManager.hxx"
+
+#include "MutexOwner.hxx"
+#include "ViewShellBase.hxx"
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
+#include <com/sun/star/frame/LayoutManagerEvents.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/compbase1.hxx>
+
+#include <vcl/timer.hxx>
+#include <sfx2/viewfrm.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star;
+
+namespace {
+typedef cppu::WeakComponentImplHelper1<frame::XLayoutManagerListener> InterfaceBase;
+}
+
+namespace sd {
+
+
+/** This implementation class not only implements the Lock() and Unlock()
+ methods but as well listens for the right combination of events to call
+ Unlock() when all is ready after the PaneManager has switched (some of)
+ its view shells.
+*/
+
+class UpdateLockManager::Implementation
+ : protected MutexOwner,
+ public InterfaceBase
+{
+public:
+ Implementation (ViewShellBase& rBase);
+ virtual ~Implementation (void);
+
+ void Lock (void);
+ void Unlock (void);
+ bool IsLocked (void) const;
+
+ /** Unlock regardless of the current lock level.
+ */
+ void ForceUnlock (void);
+
+private:
+ ViewShellBase& mrBase;
+ /// A lock level greater than 0 indicates that the ViewShellBase is locked.
+ sal_Int32 mnLockDepth;
+ /// The emergency timer to unlock the ViewShellBase when all else fails.
+ Timer maTimer;
+ /// Remember when to unlock after a layout event from frame::XLayoutManager
+ bool mbUnlockOnNextLayout;
+ /// Remember whether we are listening to the frame::XLayoutManager
+ bool mbListenerIsRegistered;
+ /// Remember whether the frame::XLayoutManager is locked.
+ bool mbLayouterIsLocked;
+ /** We hold a weak reference to the layout manager in order to have
+ access to it even when the ViewShellBase object is not valid anymore
+ and can not be used to obtain the layout manager.
+ */
+ WeakReference<frame::XLayoutManager> mxLayoutManager;
+
+ //===== frame::XLayoutEventListener =====================================
+
+ /** The event of the layouter are observed to find the best moment for
+ unlocking. This is the first layout after the lock level of the
+ layouter drops to one (we hold a lock to it ourselves which we
+ release when unlocking).
+ */
+ virtual void SAL_CALL layoutEvent (
+ const lang::EventObject& xSource,
+ sal_Int16 eLayoutEvent,
+ const Any& rInfo)
+ throw (uno::RuntimeException);
+
+ //===== lang::XEventListener ============================================
+ virtual void SAL_CALL
+ disposing (const lang::EventObject& rEventObject)
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL disposing (void);
+
+ /** This is only a fallback to make the office usable when for some
+ reason the intended way of unlocking it failed.
+ */
+ DECL_LINK(Timeout, void*);
+
+ /** Convenience method that finds the layout manager associated with the
+ frame that shows the ViewShellBase.
+ */
+ Reference<frame::XLayoutManager> GetLayoutManager (void);
+
+ Implementation (const Implementation&); // Not implemented.
+ Implementation& operator= (const Implementation&); // Not implemented.
+};
+
+
+
+
+//===== UpdateLockManager =====================================================
+
+UpdateLockManager::UpdateLockManager (ViewShellBase& rBase)
+ : mpImpl(new Implementation(rBase))
+{
+ mpImpl->acquire();
+}
+
+
+
+UpdateLockManager::~UpdateLockManager (void)
+{
+ if (mpImpl != NULL)
+ {
+ mpImpl->ForceUnlock();
+ mpImpl->release();
+ }
+}
+
+
+
+
+void UpdateLockManager::Disable (void)
+{
+ if (mpImpl != NULL)
+ {
+ mpImpl->ForceUnlock();
+ mpImpl->release();
+ mpImpl = NULL;
+ }
+}
+
+
+
+
+void UpdateLockManager::Lock (void)
+{
+ if (mpImpl != NULL)
+ mpImpl->Lock();
+}
+
+
+
+
+void UpdateLockManager::Unlock (void)
+{
+ if (mpImpl != NULL)
+ mpImpl->Unlock();
+}
+
+
+
+
+bool UpdateLockManager::IsLocked (void) const
+{
+ if (mpImpl != NULL)
+ return mpImpl->IsLocked();
+ else
+ return false;
+}
+
+
+
+//===== UpdateLock::Implementation ============================================
+
+UpdateLockManager::Implementation::Implementation (ViewShellBase& rBase)
+ : InterfaceBase(maMutex),
+ mrBase(rBase),
+ mnLockDepth(0),
+ maTimer(),
+ mbUnlockOnNextLayout(false),
+ mbListenerIsRegistered(false),
+ mbLayouterIsLocked(false)
+{
+}
+
+
+
+
+UpdateLockManager::Implementation::~Implementation (void)
+{
+ OSL_ASSERT(mnLockDepth==0);
+ ForceUnlock();
+}
+
+
+
+
+void UpdateLockManager::Implementation::Lock (void)
+{
+ ++mnLockDepth;
+ if (mnLockDepth == 1)
+ {
+ Reference<frame::XLayoutManager> xLayouter (GetLayoutManager());
+ if (xLayouter.is())
+ {
+ // Register as event listener.
+ Reference<frame::XLayoutManagerEventBroadcaster> xBroadcaster (
+ xLayouter, UNO_QUERY);
+ if (xBroadcaster.is())
+ {
+ mbListenerIsRegistered = true;
+ xBroadcaster->addLayoutManagerEventListener(
+ Reference<frame::XLayoutManagerListener> (
+ static_cast<XWeak*>(this), UNO_QUERY) );
+ }
+
+ // Lock the layout manager.
+ mbLayouterIsLocked = true;
+ xLayouter->lock();
+ }
+
+ // As a fallback, when the notification mechanism does not work (or is
+ // incorrectly used) we use a timer that will unlock us eventually.
+ maTimer.SetTimeout(5000 /*ms*/);
+ maTimer.SetTimeoutHdl(LINK(this,UpdateLockManager::Implementation,Timeout));
+ maTimer.Start();
+ }
+}
+
+
+
+
+void UpdateLockManager::Implementation::Unlock (void)
+{
+ --mnLockDepth;
+
+ if (mnLockDepth == 0)
+ {
+ // Stop the timer. We don't need it anymore.
+ maTimer.Stop();
+
+ try
+ {
+ Reference<frame::XLayoutManager> xLayouter (GetLayoutManager());
+ if (xLayouter.is())
+ {
+ // Detach from the layouter.
+ if (mbListenerIsRegistered)
+ {
+ Reference<frame::XLayoutManagerEventBroadcaster> xBroadcaster (
+ xLayouter, UNO_QUERY);
+ if (xBroadcaster.is())
+ {
+ mbListenerIsRegistered = false;
+ xBroadcaster->removeLayoutManagerEventListener(
+ Reference<frame::XLayoutManagerListener> (
+ static_cast<XWeak*>(this), UNO_QUERY) );
+ }
+ }
+
+ // Unlock the layouter.
+ if (mbLayouterIsLocked)
+ {
+ mbLayouterIsLocked = false;
+ xLayouter->unlock();
+ }
+ }
+ }
+ catch (RuntimeException)
+ { }
+
+ // Force a rearrangement of the UI elements of the views.
+ mrBase.Rearrange();
+ }
+}
+
+
+
+
+bool UpdateLockManager::Implementation::IsLocked (void) const
+{
+ return (mnLockDepth > 0);
+}
+
+
+
+
+void UpdateLockManager::Implementation::ForceUnlock (void)
+{
+ while (IsLocked())
+ Unlock();
+}
+
+
+
+
+void SAL_CALL UpdateLockManager::Implementation::layoutEvent (
+ const lang::EventObject&,
+ sal_Int16 eLayoutEvent,
+ const Any& rInfo)
+ throw (uno::RuntimeException)
+{
+ switch (eLayoutEvent)
+ {
+ case frame::LayoutManagerEvents::LOCK:
+ {
+ sal_Int32 nLockCount;
+ rInfo >>= nLockCount;
+ }
+ break;
+
+ case frame::LayoutManagerEvents::UNLOCK:
+ {
+ sal_Int32 nLockCount = 0;
+ rInfo >>= nLockCount;
+ if (nLockCount == 1)
+ {
+ // The lock count dropped to one. This means that we are
+ // the only one that still holds a lock to the layout
+ // manager. We unlock the layout manager now and the
+ // ViewShellBase on the next layout of the layout manager.
+ mbUnlockOnNextLayout = true;
+ Reference<frame::XLayoutManager> xLayouter (GetLayoutManager());
+ if (xLayouter.is() && mbLayouterIsLocked)
+ {
+ mbLayouterIsLocked = false;
+ xLayouter->unlock();
+ }
+ }
+ }
+ break;
+
+ case frame::LayoutManagerEvents::LAYOUT:
+ // Unlock when the layout manager is not still locked.
+ if (mbUnlockOnNextLayout)
+ Unlock();
+ break;
+ }
+}
+
+
+
+
+void SAL_CALL UpdateLockManager::Implementation::disposing (const lang::EventObject& )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+
+
+
+void SAL_CALL UpdateLockManager::Implementation::disposing (void)
+{
+}
+
+
+
+
+IMPL_LINK(UpdateLockManager::Implementation, Timeout, void*, EMPTYARG)
+{
+ // This method is only called when all else failed. We unlock
+ // regardless of how deep the lock depth.
+ while (mnLockDepth > 0)
+ Unlock();
+ return 1;
+}
+
+
+
+
+Reference< ::com::sun::star::frame::XLayoutManager>
+ UpdateLockManager::Implementation::GetLayoutManager (void)
+{
+ Reference<frame::XLayoutManager> xLayoutManager;
+
+ if (mxLayoutManager.get() == NULL)
+ {
+ if (mrBase.GetViewFrame()!=NULL)
+ {
+ Reference<beans::XPropertySet> xFrameProperties (
+ mrBase.GetViewFrame()->GetFrame().GetFrameInterface(),
+ UNO_QUERY);
+ if (xFrameProperties.is())
+ {
+ try
+ {
+ Any aValue (xFrameProperties->getPropertyValue(
+ ::rtl::OUString::createFromAscii("LayoutManager")));
+ aValue >>= xLayoutManager;
+ }
+ catch (const beans::UnknownPropertyException& rException)
+ {
+ (void)rException;
+ }
+ }
+ mxLayoutManager = xLayoutManager;
+ }
+ }
+ else
+ xLayoutManager = mxLayoutManager;
+
+ return xLayoutManager;
+}
+
+
+
+
+} // end of anonymous namespace
diff --git a/sd/source/ui/view/ViewClipboard.cxx b/sd/source/ui/view/ViewClipboard.cxx
new file mode 100755
index 000000000000..50c5e99ad4f9
--- /dev/null
+++ b/sd/source/ui/view/ViewClipboard.cxx
@@ -0,0 +1,278 @@
+/*************************************************************************
+ *
+ * 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 "ViewClipboard.hxx"
+
+#include "DrawDocShell.hxx"
+#include "View.hxx"
+#include "ViewShell.hxx"
+#include "Window.hxx"
+
+#include "drawdoc.hxx"
+#include "sdpage.hxx"
+#include "sdxfer.hxx"
+#include "sdresid.hxx"
+#include "glob.hrc"
+
+#include <svx/svdpagv.hxx>
+#include <vos/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+namespace sd {
+
+ViewClipboard::ViewClipboard (::sd::View& rView)
+ : mrView(rView)
+{
+}
+
+
+
+
+ViewClipboard::~ViewClipboard (void)
+{
+}
+
+
+
+
+void ViewClipboard::HandlePageDrop (const SdTransferable& rTransferable)
+{
+ // Determine whether to insert the given set of slides or to assign a
+ // given master page.
+ SdPage* pMasterPage = GetFirstMasterPage (rTransferable);
+ if (pMasterPage != NULL)
+ AssignMasterPage (rTransferable, pMasterPage);
+ else
+ InsertSlides (rTransferable, DetermineInsertPosition (rTransferable));
+}
+
+
+
+
+SdPage* ViewClipboard::GetFirstMasterPage (const SdTransferable& rTransferable)
+{
+ SdPage* pFirstMasterPage = NULL;
+
+ if (rTransferable.HasPageBookmarks())
+ {
+ do
+ {
+ const List* pBookmarks = &rTransferable.GetPageBookmarks();
+ if (pBookmarks == NULL)
+ break;
+
+ DrawDocShell* pDocShell = rTransferable.GetPageDocShell();
+ if (pDocShell == NULL)
+ break;
+
+ SdDrawDocument* pDocument = pDocShell->GetDoc();
+ if (pDocument == NULL)
+ break;
+
+ if (pBookmarks->Count() <= 0)
+ break;
+
+ int nBookmarkCount = pBookmarks->Count();
+ for (int nIndex=0; nIndex<nBookmarkCount; nIndex++)
+ {
+ String sName (*(String*) pBookmarks->GetObject(nIndex));
+ sal_Bool bIsMasterPage;
+
+ // SdPage* GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind);
+ // sal_uInt16 GetMasterSdPageCount(PageKind ePgKind) const;
+
+ sal_uInt16 nBMPage = pDocument->GetPageByName (
+ sName, bIsMasterPage);
+ if ( ! bIsMasterPage)
+ {
+ // At least one regular slide: return NULL to indicate
+ // that not all bookmarks point to master pages.
+ pFirstMasterPage = NULL;
+ break;
+ }
+ else if (pFirstMasterPage == NULL)
+ {
+ // Remember the first master page for later.
+ if (nBMPage != SDRPAGE_NOTFOUND)
+ pFirstMasterPage = static_cast<SdPage*>(
+ pDocument->GetMasterPage(nBMPage));
+ }
+ }
+ }
+ while (false);
+ }
+
+ return pFirstMasterPage;
+}
+
+
+
+
+void ViewClipboard::AssignMasterPage (
+ const SdTransferable& rTransferable,
+ SdPage* pMasterPage)
+{
+ do
+ {
+ if (pMasterPage == NULL)
+ return;
+
+ // Get the target page to which the master page is assigned.
+ SdrPageView* pPageView = mrView.GetSdrPageView();
+ if (pPageView == NULL)
+ break;
+
+ SdPage* pPage = static_cast<SdPage*>(pPageView->GetPage());
+ if (pPage == NULL)
+ break;
+
+ SdDrawDocument* pDocument = mrView.GetDoc();
+ if (pDocument == NULL)
+ break;
+
+ if ( ! rTransferable.HasPageBookmarks())
+ break;
+
+ DrawDocShell* pDataDocShell = rTransferable.GetPageDocShell();
+ if (pDataDocShell == NULL)
+ break;
+
+ SdDrawDocument* pSourceDocument = pDataDocShell->GetDoc();
+ if (pSourceDocument == NULL)
+ break;
+
+ // We have to remove the layout suffix from the layout name which is
+ // appended again by SetMasterPage() to the given name. Don't ask.
+ String sLayoutSuffix (RTL_CONSTASCII_STRINGPARAM(SD_LT_SEPARATOR));
+ sLayoutSuffix.Append (SdResId(STR_LAYOUT_OUTLINE));
+ sal_uInt16 nLength = sLayoutSuffix.Len();
+ String sLayoutName (pMasterPage->GetLayoutName());
+ if (String(sLayoutName, sLayoutName.Len()-nLength, nLength).Equals (
+ sLayoutSuffix))
+ sLayoutName = String(sLayoutName, 0, sLayoutName.Len()-nLength);
+
+ pDocument->SetMasterPage (
+ pPage->GetPageNum() / 2,
+ sLayoutName,
+ pSourceDocument,
+ sal_False, // Exchange the master page of only the target page.
+ sal_False // Keep unused master pages.
+ );
+ }
+ while (false);
+}
+
+
+
+
+sal_uInt16 ViewClipboard::DetermineInsertPosition (
+ const SdTransferable& )
+{
+ SdDrawDocument* pDoc = mrView.GetDoc();
+ sal_uInt16 nPgCnt = pDoc->GetSdPageCount( PK_STANDARD );
+
+ // Insert position is the behind the last selected page or behind the
+ // last page when the selection is empty.
+ sal_uInt16 nInsertPos = pDoc->GetSdPageCount( PK_STANDARD ) * 2 + 1;
+ for( sal_uInt16 nPage = 0; nPage < nPgCnt; nPage++ )
+ {
+ SdPage* pPage = pDoc->GetSdPage( nPage, PK_STANDARD );
+
+ if( pPage->IsSelected() )
+ nInsertPos = nPage * 2 + 3;
+ }
+
+ return nInsertPos;
+}
+
+
+
+
+sal_uInt16 ViewClipboard::InsertSlides (
+ const SdTransferable& rTransferable,
+ sal_uInt16 nInsertPosition)
+{
+ SdDrawDocument* pDoc = mrView.GetDoc();
+
+ sal_uInt16 nInsertPgCnt = 0;
+ sal_Bool bMergeMasterPages = !rTransferable.HasSourceDoc( pDoc );
+
+ // Prepare the insertion.
+ const List* pBookmarkList;
+ DrawDocShell* pDataDocSh;
+ if (rTransferable.HasPageBookmarks())
+ {
+ // When the transferable contains page bookmarks then the referenced
+ // pages are inserted.
+ pBookmarkList = &rTransferable.GetPageBookmarks();
+ pDataDocSh = rTransferable.GetPageDocShell();
+ nInsertPgCnt = (sal_uInt16)pBookmarkList->Count();
+ }
+ else
+ {
+ // Otherwise all pages of the document of the transferable are
+ // inserted.
+ SfxObjectShell* pShell = rTransferable.GetDocShell();
+ pDataDocSh = (DrawDocShell*) pShell;
+ SdDrawDocument* pDataDoc = pDataDocSh->GetDoc();
+ pBookmarkList = NULL;
+ if (pDataDoc!=NULL && pDataDoc->GetSdPageCount(PK_STANDARD))
+ nInsertPgCnt = pDataDoc->GetSdPageCount(PK_STANDARD);
+ }
+ if (nInsertPgCnt > 0)
+ {
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ ::sd::Window* pWin = mrView.GetViewShell()->GetActiveWindow();
+ const sal_Bool bWait = pWin && pWin->IsWait();
+
+ if( bWait )
+ pWin->LeaveWait();
+
+ pDoc->InsertBookmarkAsPage(
+ const_cast<List*>(pBookmarkList),
+ NULL,
+ sal_False,
+ sal_False,
+ nInsertPosition,
+ (&rTransferable == SD_MOD()->pTransferDrag),
+ pDataDocSh,
+ sal_True,
+ bMergeMasterPages,
+ sal_False);
+
+ if( bWait )
+ pWin->EnterWait();
+ }
+
+ return nInsertPgCnt;
+}
+
+
+} // end of namespace ::sd
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
new file mode 100644
index 000000000000..0ad6f09223dd
--- /dev/null
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -0,0 +1,1735 @@
+/*************************************************************************
+ *
+ * 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 <comphelper/processfactory.hxx>
+
+#include <com/sun/star/frame/UnknownModuleException.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#include "ViewShellBase.hxx"
+#include <algorithm>
+#include "EventMultiplexer.hxx"
+#include "cache/SlsPageCacheManager.hxx"
+#include "sdresid.hxx"
+#include "app.hrc"
+#include "strings.hrc"
+#include "glob.hrc"
+#include "unokywds.hxx"
+#include <svx/svxids.hrc>
+#include "DrawDocShell.hxx"
+#include <sfx2/app.hxx>
+#include "PaneChildWindows.hxx"
+#include "NotesChildWindow.hxx"
+#include "ViewShellManager.hxx"
+#include "DrawController.hxx"
+#include "UpdateLockManager.hxx"
+#include "FrameView.hxx"
+#include "ViewTabBar.hxx"
+#include <sfx2/event.hxx>
+#include "drawdoc.hxx"
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/printer.hxx>
+#include "DrawViewShell.hxx"
+#include "GraphicViewShell.hxx"
+#include "OutlineViewShell.hxx"
+#include "SlideSorterViewShell.hxx"
+#include "PresentationViewShell.hxx"
+#include "FormShellManager.hxx"
+#include "ToolBarManager.hxx"
+#include "taskpane/PanelId.hxx"
+#include "Window.hxx"
+#include "framework/ConfigurationController.hxx"
+#include "DocumentRenderer.hxx"
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/document/XViewDataSupplier.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+#include <com/sun/star/drawing/framework/ResourceId.hpp>
+#include "framework/FrameworkHelper.hxx"
+
+#include <rtl/ref.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/objface.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/whiter.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/diagnose_ex.h>
+
+#include "fubullet.hxx"
+
+using namespace sd;
+#define ViewShellBase
+#include "sdslots.hxx"
+
+using ::sd::framework::FrameworkHelper;
+using ::rtl::OUString;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::container;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+
+namespace {
+
+class CurrentPageSetter
+{
+public:
+ CurrentPageSetter (ViewShellBase& rBase);
+ void operator () (bool);
+private:
+ ViewShellBase& mrBase;
+};
+
+} // end of anonymous namespace
+
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+using ::sd::framework::FrameworkHelper;
+
+namespace sd {
+
+class ViewShellBase::Implementation
+{
+public:
+ /** Main controller of the view shell. During the switching from one
+ stacked shell to another this pointer may be NULL.
+ */
+ ::rtl::Reference<DrawController> mpController;
+
+ /** The view tab bar is the control for switching between different
+ views in one pane.
+ */
+ ::rtl::Reference<ViewTabBar> mpViewTabBar;
+
+ // contains the complete area of the current view relative to the frame window
+ Rectangle maClientArea;
+
+ // This is set to true when PrepareClose() is called.
+ bool mbIsClosing;
+
+ /** The view window is the parent of all UI elements that belong to the
+ view or ViewShell. This comprises the rulers, the scroll bars, and
+ the content window.
+ It does not include the ViewTabBar.
+ */
+ ::boost::scoped_ptr< ::Window> mpViewWindow;
+
+ ::boost::shared_ptr<ToolBarManager> mpToolBarManager;
+
+ ::boost::shared_ptr<ViewShellManager> mpViewShellManager;
+
+ ::boost::shared_ptr<tools::EventMultiplexer> mpEventMultiplexer;
+
+ ::boost::shared_ptr<UpdateLockManager> mpUpdateLockManager;
+
+ ::boost::shared_ptr<FormShellManager> mpFormShellManager;
+
+ Implementation (ViewShellBase& rBase);
+ ~Implementation (void);
+
+ void LateInit (void);
+
+ /** Show or hide the ViewTabBar.
+ @param bShow
+ When <TRUE/> then the ViewTabBar is shown, otherwise it is hidden.
+ */
+ void ShowViewTabBar (bool bShow);
+
+ /** Common code of ViewShellBase::OuterResizePixel() and
+ ViewShellBase::InnerResizePixel().
+ */
+ void ResizePixel (
+ const Point& rOrigin,
+ const Size& rSize,
+ bool bOuterResize);
+
+ /** Show or hide the specified pane. The visibility state is taken
+ fromthe given request.
+ @param rRequest
+ The request determines the new visibility state. The state can
+ either be toggled or be set to a given value.
+ @param rsPaneURL
+ This URL specifies the pane whose visibility state to set.
+ @param rsViewURL
+ When the pane becomes visible then this view URL specifies which
+ type of view to show in it.
+ */
+ void SetPaneVisibility (
+ const SfxRequest& rRequest,
+ const ::rtl::OUString& rsPaneURL,
+ const ::rtl::OUString& rsViewURL);
+
+ void GetSlotState (SfxItemSet& rSet);
+
+ void ProcessRestoreEditingViewSlot (void);
+ void ProcessTaskPaneSlot (SfxRequest& rRequest);
+
+private:
+ ViewShellBase& mrBase;
+
+ /** Hold a reference to the page cache manager of the slide sorter in
+ order to ensure that it stays alive while the ViewShellBase is
+ alive.
+ */
+ ::boost::shared_ptr<slidesorter::cache::PageCacheManager> mpPageCacheManager;
+};
+
+
+namespace {
+/** The only task of this window is to forward key presses to the content
+ window of the main view shell. With the key press it forwards the focus
+ so that it is not called very often.
+*/
+class FocusForwardingWindow : public ::Window
+{
+public:
+ FocusForwardingWindow (::Window& rParentWindow, ViewShellBase& rBase);
+ virtual ~FocusForwardingWindow (void);
+ virtual void KeyInput (const KeyEvent& rEvent);
+ virtual void Command (const CommandEvent& rEvent);
+
+private:
+ ViewShellBase& mrBase;
+};
+} // end of anonymous namespace
+
+
+//===== ViewShellBase =========================================================
+
+TYPEINIT1(ViewShellBase, SfxViewShell);
+
+// We have to expand the SFX_IMPL_VIEWFACTORY macro to call LateInit() after a
+// new ViewShellBase object has been constructed.
+
+SfxViewFactory* ViewShellBase::pFactory;
+SfxViewShell* __EXPORT ViewShellBase::CreateInstance (
+ SfxViewFrame *pFrame, SfxViewShell *pOldView)
+{
+ ViewShellBase* pBase = new ViewShellBase(pFrame, pOldView);
+ pBase->LateInit(OUString());
+ return pBase;
+}
+void ViewShellBase::RegisterFactory( sal_uInt16 nPrio )
+{
+ pFactory = new SfxViewFactory(
+ &CreateInstance,&InitFactory,nPrio,"Default");
+ InitFactory();
+}
+void ViewShellBase::InitFactory()
+{
+ SFX_VIEW_REGISTRATION(DrawDocShell);
+}
+
+
+
+SFX_IMPL_INTERFACE(ViewShellBase, SfxViewShell, SdResId(STR_VIEWSHELLBASE))
+{
+}
+
+
+
+
+ViewShellBase::ViewShellBase (
+ SfxViewFrame* _pFrame,
+ SfxViewShell*)
+ : SfxViewShell (_pFrame,
+ SFX_VIEW_CAN_PRINT
+ | SFX_VIEW_HAS_PRINTOPTIONS),
+ maMutex(),
+ mpImpl(),
+ mpDocShell (NULL),
+ mpDocument (NULL)
+{
+ mpImpl.reset(new Implementation(*this));
+ mpImpl->mpViewWindow.reset(new FocusForwardingWindow(_pFrame->GetWindow(),*this));
+ mpImpl->mpViewWindow->SetBackground(Wallpaper());
+ mpImpl->mpUpdateLockManager.reset(new UpdateLockManager(*this));
+
+ _pFrame->GetWindow().SetBackground(Wallpaper());
+
+ // Set up the members in the correct order.
+ if (GetViewFrame()->GetObjectShell()->ISA(DrawDocShell))
+ mpDocShell = static_cast<DrawDocShell*>(
+ GetViewFrame()->GetObjectShell());
+ if (mpDocShell != NULL)
+ mpDocument = mpDocShell->GetDoc();
+ mpImpl->mpViewShellManager.reset(new ViewShellManager(*this));
+
+ SetWindow(mpImpl->mpViewWindow.get());
+
+ // Hide the window to avoid complaints from Sfx...SwitchViewShell...
+ _pFrame->GetWindow().Hide();
+}
+
+
+
+
+/** In this destructor the order in which some of the members are destroyed
+ (and/or being prepared to being destroyed) is important. Change it only
+ when you know what you are doing.
+*/
+ViewShellBase::~ViewShellBase (void)
+{
+ // Tell the controller that the ViewShellBase is not available anymore.
+ if (mpImpl->mpController.get() != NULL)
+ mpImpl->mpController->ReleaseViewShellBase();
+
+ // We have to hide the main window to prevent SFX complaining after a
+ // reload about it being already visible.
+ ViewShell* pShell = GetMainViewShell().get();
+ if (pShell!=NULL
+ && pShell->GetActiveWindow()!=NULL
+ && pShell->GetActiveWindow()->GetParent()!=NULL)
+ {
+ pShell->GetActiveWindow()->GetParent()->Hide();
+ }
+
+ mpImpl->mpUpdateLockManager->Disable();
+ mpImpl->mpToolBarManager->Shutdown();
+ mpImpl->mpViewShellManager->Shutdown();
+
+ EndListening(*GetViewFrame());
+ EndListening(*GetDocShell());
+
+ SetWindow(NULL);
+}
+
+
+
+
+void ViewShellBase::LateInit (const ::rtl::OUString& rsDefaultView)
+{
+ StartListening(*GetViewFrame(),sal_True);
+ StartListening(*GetDocShell(),sal_True);
+ mpImpl->LateInit();
+ InitializeFramework();
+
+ mpImpl->mpEventMultiplexer.reset(new tools::EventMultiplexer (*this));
+
+ mpImpl->mpFormShellManager.reset(new FormShellManager(*this));
+
+ mpImpl->mpToolBarManager = ToolBarManager::Create(
+ *this,
+ mpImpl->mpEventMultiplexer,
+ mpImpl->mpViewShellManager);
+
+ try
+ {
+ Reference<XControllerManager> xControllerManager (GetDrawController(), UNO_QUERY_THROW);
+ Reference<XConfigurationController> xConfigurationController (
+ xControllerManager->getConfigurationController());
+ if (xConfigurationController.is())
+ {
+ OUString sView (rsDefaultView);
+ if (sView.getLength() == 0)
+ sView = GetInitialViewShellType();
+
+ ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(*this));
+
+ // Create the resource ids for the center pane and view.
+ const Reference<drawing::framework::XResourceId> xCenterPaneId (
+ pHelper->CreateResourceId(FrameworkHelper::msCenterPaneURL));
+ const Reference<drawing::framework::XResourceId> xCenterViewId (
+ pHelper->CreateResourceId(sView, xCenterPaneId));
+
+ // Request center pane and view.
+ xConfigurationController->requestResourceActivation(xCenterPaneId, ResourceActivationMode_ADD);
+ xConfigurationController->requestResourceActivation(xCenterViewId, ResourceActivationMode_REPLACE);
+
+ // Process configuration events synchronously until the center view
+ // has been created.
+ sd::framework::ConfigurationController* pConfigurationController
+ = dynamic_cast<sd::framework::ConfigurationController*>(xConfigurationController.get());
+ if (pConfigurationController != NULL)
+ {
+ while (
+ ! pConfigurationController->getResource(xCenterViewId).is()
+ && pConfigurationController->hasPendingRequests())
+ {
+ pConfigurationController->ProcessEvent();
+ }
+ }
+ }
+ }
+ catch (RuntimeException&)
+ {}
+
+ // AutoLayouts have to be ready.
+ GetDocument()->StopWorkStartupDelay();
+
+ UpdateBorder();
+
+ // Remember the type of the current main view shell in the frame view.
+ ViewShell* pViewShell = GetMainViewShell().get();
+ if (pViewShell != NULL)
+ {
+ FrameView* pFrameView = pViewShell->GetFrameView();
+ if (pFrameView != NULL)
+ pFrameView->SetViewShellTypeOnLoad(pViewShell->GetShellType());
+ }
+}
+
+
+
+
+::boost::shared_ptr<ViewShellManager> ViewShellBase::GetViewShellManager (void) const
+{
+ return mpImpl->mpViewShellManager;
+}
+
+
+
+
+::boost::shared_ptr<ViewShell> ViewShellBase::GetMainViewShell (void) const
+{
+ ::boost::shared_ptr<ViewShell> pMainViewShell (
+ framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))
+ ->GetViewShell(framework::FrameworkHelper::msCenterPaneURL));
+ if (pMainViewShell.get() == NULL)
+ pMainViewShell = framework::FrameworkHelper::Instance(*const_cast<ViewShellBase*>(this))
+ ->GetViewShell(framework::FrameworkHelper::msFullScreenPaneURL);
+ return pMainViewShell;
+}
+
+
+
+
+ViewShellBase* ViewShellBase::GetViewShellBase (SfxViewFrame* pViewFrame)
+{
+ ViewShellBase* pBase = NULL;
+
+ if (pViewFrame != NULL)
+ {
+ // Get the view shell for the frame and cast it to
+ // sd::ViewShellBase.
+ SfxViewShell* pSfxViewShell = pViewFrame->GetViewShell();
+ if (pSfxViewShell!=NULL && pSfxViewShell->ISA(::sd::ViewShellBase))
+ pBase = static_cast<ViewShellBase*>(pSfxViewShell);
+ }
+
+ return pBase;
+}
+
+
+
+
+DrawDocShell* ViewShellBase::GetDocShell (void) const
+{
+ return mpDocShell;
+}
+
+
+
+SdDrawDocument* ViewShellBase::GetDocument (void) const
+{
+ return mpDocument;
+}
+
+
+
+
+void ViewShellBase::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ SfxViewShell::Notify(rBC, rHint);
+
+ if (rHint.IsA(TYPE(SfxEventHint)))
+ {
+ switch (static_cast<const SfxEventHint&>(rHint).GetEventId())
+ {
+ case SFX_EVENT_OPENDOC:
+ if( GetDocument() && GetDocument()->IsStartWithPresentation() )
+ {
+ if( GetViewFrame() )
+ {
+ GetDocument()->SetStartWithPresentation( false );
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON );
+ }
+ }
+ else
+ {
+ // mpPaneManager->InitPanes();
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+
+
+
+void ViewShellBase::InitializeFramework (void)
+{
+}
+
+
+
+
+void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize)
+{
+ Size aObjSize = GetObjectShell()->GetVisArea().GetSize();
+ if ( aObjSize.Width() > 0 && aObjSize.Height() > 0 )
+ {
+ SvBorder aBorder( GetBorderPixel() );
+ Size aSize( rSize );
+ aSize.Width() -= (aBorder.Left() + aBorder.Right());
+ aSize.Height() -= (aBorder.Top() + aBorder.Bottom());
+ Size aObjSizePixel = mpImpl->mpViewWindow->LogicToPixel( aObjSize, MAP_100TH_MM );
+ SfxViewShell::SetZoomFactor(
+ Fraction( aSize.Width(), std::max( aObjSizePixel.Width(), (long int)1 ) ),
+ Fraction( aSize.Height(), std::max( aObjSizePixel.Height(), (long int)1) ) );
+ }
+
+ mpImpl->ResizePixel(rOrigin, rSize, false);
+}
+
+
+
+
+void ViewShellBase::OuterResizePixel (const Point& rOrigin, const Size &rSize)
+{
+ mpImpl->ResizePixel (rOrigin, rSize, true);
+}
+
+
+
+
+void ViewShellBase::Rearrange (void)
+{
+ OSL_ASSERT(GetViewFrame()!=NULL);
+
+ // There is a bug in the communication between embedded objects and the
+ // framework::LayoutManager that leads to missing resize updates. The
+ // following workaround enforces such an update by cycling the border to
+ // zero and back to the current value.
+ if (GetWindow() != NULL)
+ {
+ SetBorderPixel(SvBorder());
+ UpdateBorder(true);
+ }
+ else
+ {
+ OSL_TRACE("Rearrange: window missing");
+ }
+
+ GetViewFrame()->Resize(sal_True);
+}
+
+
+
+
+ErrCode ViewShellBase::DoVerb (long nVerb)
+{
+ ErrCode aResult = ERRCODE_NONE;
+
+ ::sd::ViewShell* pShell = GetMainViewShell().get();
+ if (pShell != NULL)
+ aResult = pShell->DoVerb (nVerb);
+
+ return aResult;
+}
+
+
+
+
+Reference<view::XRenderable> ViewShellBase::GetRenderable (void)
+{
+ // Create a new DocumentRenderer on every call. It observes the life
+ // time of this ViewShellBase object.
+ return Reference<view::XRenderable>(new DocumentRenderer(*this));
+}
+
+
+
+
+SfxPrinter* ViewShellBase::GetPrinter (sal_Bool bCreate)
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+
+ return GetDocShell()->GetPrinter (bCreate);
+}
+
+
+
+
+sal_uInt16 ViewShellBase::SetPrinter (
+ SfxPrinter* pNewPrinter,
+ sal_uInt16 nDiffFlags,
+ bool bIsAPI)
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+
+ GetDocShell()->SetPrinter(pNewPrinter);
+
+ if ( (nDiffFlags & SFX_PRINTER_CHG_ORIENTATION ||
+ nDiffFlags & SFX_PRINTER_CHG_SIZE) && pNewPrinter )
+ {
+ MapMode aMap = pNewPrinter->GetMapMode();
+ aMap.SetMapUnit(MAP_100TH_MM);
+ MapMode aOldMap = pNewPrinter->GetMapMode();
+ pNewPrinter->SetMapMode(aMap);
+ Size aNewSize = pNewPrinter->GetOutputSize();
+
+ sal_Bool bScaleAll = sal_False;
+ if ( bIsAPI )
+ {
+ WarningBox aWarnBox (
+ GetWindow(),
+ (WinBits)(WB_YES_NO | WB_DEF_YES),
+ String(SdResId(STR_SCALE_OBJS_TO_PAGE)));
+ bScaleAll = (aWarnBox.Execute() == RET_YES);
+ }
+
+ ::boost::shared_ptr<DrawViewShell> pDrawViewShell (
+ ::boost::dynamic_pointer_cast<DrawViewShell>(GetMainViewShell()));
+ if (pDrawViewShell)
+ {
+ SdPage* pPage = GetDocument()->GetSdPage(
+ 0, PK_STANDARD );
+ pDrawViewShell->SetPageSizeAndBorder (
+ pDrawViewShell->GetPageKind(),
+ aNewSize,
+ -1,-1,-1,-1,
+ bScaleAll,
+ pNewPrinter->GetOrientation(),
+ pPage->GetPaperBin(),
+ pPage->IsBackgroundFullSize());
+ }
+
+ pNewPrinter->SetMapMode(aOldMap);
+ }
+
+ return 0;
+}
+
+
+
+
+SfxTabPage* ViewShellBase::CreatePrintOptionsPage(
+ ::Window *pParent,
+ const SfxItemSet &rOptions)
+{
+ (void)pParent;
+ (void)rOptions;
+ return NULL;
+ // return mpImpl->mpPrintManager->CreatePrintOptionsPage (pParent, rOptions);
+}
+
+
+
+
+void ViewShellBase::UIActivating( SfxInPlaceClient* pClient )
+{
+ mpImpl->ShowViewTabBar(false);
+
+ ViewShell* pViewShell = GetMainViewShell().get();
+ if ( pViewShell )
+ pViewShell->UIActivating( pClient );
+
+ SfxViewShell::UIActivating( pClient );
+}
+
+
+
+
+void ViewShellBase::UIDeactivated( SfxInPlaceClient* pClient )
+{
+ SfxViewShell::UIDeactivated( pClient );
+
+ mpImpl->ShowViewTabBar(true);
+
+ ViewShell* pViewShell = GetMainViewShell().get();
+ if ( pViewShell )
+ pViewShell->UIDeactivated( pClient );
+}
+
+
+
+
+SvBorder ViewShellBase::GetBorder (bool )
+{
+ int nTop = 0;
+ if (mpImpl->mpViewTabBar.is() && mpImpl->mpViewTabBar->GetTabControl()->IsVisible())
+ nTop = mpImpl->mpViewTabBar->GetHeight();
+ return SvBorder(0,nTop,0,0);
+}
+
+
+
+
+void ViewShellBase::Execute (SfxRequest& rRequest)
+{
+ sal_uInt16 nSlotId = rRequest.GetSlot();
+
+ switch (nSlotId)
+ {
+ case SID_SWITCH_SHELL:
+ {
+ Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
+ if (xControllerManager.is())
+ {
+ Reference<XConfigurationController> xConfigurationController (
+ xControllerManager->getConfigurationController());
+ if (xConfigurationController.is())
+ xConfigurationController->update();
+ }
+ }
+ break;
+
+ case SID_LEFT_PANE_DRAW:
+ mpImpl->SetPaneVisibility(
+ rRequest,
+ framework::FrameworkHelper::msLeftDrawPaneURL,
+ framework::FrameworkHelper::msSlideSorterURL);
+ break;
+
+ case SID_LEFT_PANE_IMPRESS:
+ mpImpl->SetPaneVisibility(
+ rRequest,
+ framework::FrameworkHelper::msLeftImpressPaneURL,
+ framework::FrameworkHelper::msSlideSorterURL);
+ break;
+
+ case SID_TASKPANE:
+ mpImpl->SetPaneVisibility(
+ rRequest,
+ framework::FrameworkHelper::msRightPaneURL,
+ framework::FrameworkHelper::msTaskPaneURL);
+ break;
+
+ case SID_NORMAL_MULTI_PANE_GUI:
+ case SID_SLIDE_SORTER_MULTI_PANE_GUI:
+ case SID_DRAWINGMODE:
+ case SID_DIAMODE:
+ case SID_OUTLINEMODE:
+ case SID_NOTESMODE:
+ case SID_HANDOUTMODE:
+ framework::FrameworkHelper::Instance(*this)->HandleModeChangeSlot(nSlotId, rRequest);
+ break;
+
+ case SID_WIN_FULLSCREEN:
+ // The full screen mode is not supported. Ignore the request.
+ break;
+
+ case SID_SHOW_TOOL_PANEL:
+ mpImpl->ProcessTaskPaneSlot(rRequest);
+ break;
+
+ case SID_RESTORE_EDITING_VIEW:
+ mpImpl->ProcessRestoreEditingViewSlot();
+ break;
+
+ default:
+ // Ignore any other slot.
+ rRequest.Ignore ();
+ break;
+ }
+}
+
+
+
+
+void ViewShellBase::GetState (SfxItemSet& rSet)
+{
+ // The full screen mode is not supported. Disable the the slot so that
+ // it appears grayed out when somebody uses configures the menu to show
+ // an menu item for it.
+ // if (rSet.GetItemState(SID_WIN_FULLSCREEN) == SFX_ITEM_AVAILABLE)
+ // rSet.DisableItem(SID_WIN_FULLSCREEN);
+
+ mpImpl->GetSlotState(rSet);
+
+ FuBullet::GetSlotState( rSet, 0, GetViewFrame() );
+}
+
+
+
+
+void ViewShellBase::WriteUserDataSequence (
+ ::com::sun::star::uno::Sequence <
+ ::com::sun::star::beans::PropertyValue >& rSequence,
+ sal_Bool bBrowse)
+{
+ // Forward call to main sub shell.
+ ViewShell* pShell = GetMainViewShell().get();
+ if (pShell != NULL)
+ pShell->WriteUserDataSequence (rSequence, bBrowse);
+}
+
+
+
+
+void ViewShellBase::ReadUserDataSequence (
+ const ::com::sun::star::uno::Sequence <
+ ::com::sun::star::beans::PropertyValue >& rSequence,
+ sal_Bool bBrowse)
+{
+ // Forward call to main sub shell.
+ ViewShell* pShell = GetMainViewShell().get();
+ if (pShell != NULL)
+ {
+ pShell->ReadUserDataSequence (rSequence, bBrowse);
+
+ // For certain shell types ReadUserDataSequence may have changed the
+ // type to another one. Make sure that the center pane shows the
+ // right view shell.
+ switch (pShell->GetShellType())
+ {
+ case ViewShell::ST_IMPRESS:
+ case ViewShell::ST_NOTES:
+ case ViewShell::ST_HANDOUT:
+ {
+ ::rtl::OUString sViewURL;
+ switch (PTR_CAST(DrawViewShell, pShell)->GetPageKind())
+ {
+ default:
+ case PK_STANDARD:
+ sViewURL = framework::FrameworkHelper::msImpressViewURL;
+ break;
+ case PK_NOTES:
+ sViewURL = framework::FrameworkHelper::msNotesViewURL;
+ break;
+ case PK_HANDOUT:
+ sViewURL = framework::FrameworkHelper::msHandoutViewURL;
+ break;
+ }
+ if (sViewURL.getLength() > 0)
+ framework::FrameworkHelper::Instance(*this)->RequestView(
+ sViewURL,
+ framework::FrameworkHelper::msCenterPaneURL);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+
+
+
+void ViewShellBase::Activate (sal_Bool bIsMDIActivate)
+{
+ SfxViewShell::Activate(bIsMDIActivate);
+
+ Reference<XControllerManager> xControllerManager (GetController(), UNO_QUERY);
+ if (xControllerManager.is())
+ {
+ Reference<XConfigurationController> xConfigurationController (
+ xControllerManager->getConfigurationController());
+ if (xConfigurationController.is())
+ xConfigurationController->update();
+ }
+ GetToolBarManager()->RequestUpdate();
+}
+
+
+
+
+void ViewShellBase::Deactivate (sal_Bool bIsMDIActivate)
+{
+ SfxViewShell::Deactivate(bIsMDIActivate);
+}
+
+
+
+
+void ViewShellBase::SetZoomFactor (
+ const Fraction &rZoomX,
+ const Fraction &rZoomY)
+{
+ SfxViewShell::SetZoomFactor (rZoomX, rZoomY);
+ // Forward call to main sub shell.
+ ViewShell* pShell = GetMainViewShell().get();
+ if (pShell != NULL)
+ pShell->SetZoomFactor (rZoomX, rZoomY);
+}
+
+
+
+
+sal_uInt16 ViewShellBase::PrepareClose (sal_Bool bUI, sal_Bool bForBrowsing)
+{
+ sal_uInt16 nResult = SfxViewShell::PrepareClose (bUI, bForBrowsing);
+
+ if (nResult == sal_True)
+ {
+ mpImpl->mbIsClosing = true;
+
+ // Forward call to main sub shell.
+ ViewShell* pShell = GetMainViewShell().get();
+ if (pShell != NULL)
+ nResult = pShell->PrepareClose (bUI, bForBrowsing);
+ }
+
+ return nResult;
+}
+
+
+
+
+void ViewShellBase::WriteUserData (String& rString, sal_Bool bBrowse)
+{
+ SfxViewShell::WriteUserData (rString, bBrowse);
+
+ // Forward call to main sub shell.
+ ViewShell* pShell = GetMainViewShell().get();
+ if (pShell != NULL)
+ pShell->WriteUserData (rString);
+}
+
+
+
+
+void ViewShellBase::ReadUserData (const String& rString, sal_Bool bBrowse)
+{
+ SfxViewShell::ReadUserData (rString, bBrowse);
+
+ // Forward call to main sub shell.
+ ViewShell* pShell = GetMainViewShell().get();
+ if (pShell != NULL)
+ pShell->ReadUserData (rString);
+}
+
+
+
+
+SdrView* ViewShellBase::GetDrawView (void) const
+{
+ // Forward call to main sub shell.
+ ViewShell* pShell = GetMainViewShell().get();
+ if (pShell != NULL)
+ return pShell->GetDrawView ();
+ else
+ return SfxViewShell::GetDrawView();
+}
+
+
+
+
+void ViewShellBase::AdjustPosSizePixel (const Point &rOfs, const Size &rSize)
+{
+ SfxViewShell::AdjustPosSizePixel (rOfs, rSize);
+}
+
+
+
+
+void ViewShellBase::SetBusyState (bool bBusy)
+{
+ if (GetDocShell() != NULL)
+ GetDocShell()->SetWaitCursor (bBusy);
+}
+
+
+
+
+void ViewShellBase::UpdateBorder ( bool bForce /* = false */ )
+{
+ // The following calls to SetBorderPixel() and InvalidateBorder() are
+ // made only for the main view shell. This not only avoids unnecessary
+ // calls for the views in side panes but prevents calling an already
+ // dying SfxViewShell base class.
+ // For issue #140703# we have to check the existence of the window,
+ // too. The SfxViewFrame accesses the window without checking it.
+ ViewShell* pMainViewShell = GetMainViewShell().get();
+ if (pMainViewShell != NULL && GetWindow()!=NULL)
+ {
+ SvBorder aCurrentBorder (GetBorderPixel());
+ bool bOuterResize ( ! GetDocShell()->IsInPlaceActive());
+ SvBorder aBorder (GetBorder(bOuterResize));
+ aBorder += pMainViewShell->GetBorder(bOuterResize);
+
+ if (bForce || (aBorder != aCurrentBorder))
+ {
+ SetBorderPixel (aBorder);
+ InvalidateBorder();
+ }
+ }
+}
+
+
+
+
+void ViewShellBase::ShowUIControls (bool bVisible)
+{
+ if (mpImpl->mpViewTabBar.is())
+ mpImpl->mpViewTabBar->GetTabControl()->Show(bVisible);
+
+ ViewShell* pMainViewShell = GetMainViewShell().get();
+ if (pMainViewShell != NULL)
+ pMainViewShell->ShowUIControls (bVisible);
+
+ UpdateBorder();
+ if (bVisible)
+ Rearrange();
+}
+
+
+
+
+OUString ViewShellBase::GetInitialViewShellType (void)
+{
+ OUString sRequestedView (FrameworkHelper::msImpressViewURL);
+
+ do
+ {
+ Reference<document::XViewDataSupplier> xViewDataSupplier (
+ GetDocShell()->GetModel(), UNO_QUERY);
+ if ( ! xViewDataSupplier.is())
+ break;
+
+ Reference<container::XIndexAccess> xViewData (xViewDataSupplier->getViewData());
+ if ( ! xViewData.is())
+ break;
+ if (xViewData->getCount() == 0)
+ break;
+
+ sal_Int32 nView = 0;
+ ::com::sun::star::uno::Any aAny = xViewData->getByIndex(nView);
+ Sequence<beans::PropertyValue> aProperties;
+ if ( ! (aAny >>= aProperties))
+ break;
+
+ // Search the properties for the one that tells us what page kind to
+ // use.
+ for (sal_Int32 n=0; n<aProperties.getLength(); n++)
+ {
+ const beans::PropertyValue& rProperty (aProperties[n]);
+ if (rProperty.Name.compareToAscii(sUNO_View_PageKind) == COMPARE_EQUAL)
+ {
+ sal_Int16 nPageKind = 0;
+ rProperty.Value >>= nPageKind;
+ switch ((PageKind)nPageKind)
+ {
+ case PK_STANDARD:
+ sRequestedView = FrameworkHelper::msImpressViewURL;
+ break;
+
+ case PK_HANDOUT:
+ sRequestedView = FrameworkHelper::msHandoutViewURL;
+ break;
+
+ case PK_NOTES:
+ sRequestedView = FrameworkHelper::msNotesViewURL;
+ break;
+
+ default:
+ // The page kind is invalid. This is propably an
+ // error by the caller. We use the standard type to
+ // keep things going.
+ DBG_ASSERT(sal_False, "ViewShellBase::GetInitialViewShellType: invalid page kind");
+ sRequestedView = FrameworkHelper::msImpressViewURL;
+ break;
+ }
+ break;
+ }
+ }
+ }
+ while (false);
+
+ return sRequestedView;
+}
+
+
+
+
+/** this method starts the presentation by
+ executing the slot SID_PRESENTATION asynchronous */
+void ViewShellBase::StartPresentation()
+{
+ if( GetViewFrame() && GetViewFrame()->GetDispatcher() )
+ GetViewFrame()->GetDispatcher()->Execute(SID_PRESENTATION, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+}
+
+
+
+
+
+::boost::shared_ptr<tools::EventMultiplexer> ViewShellBase::GetEventMultiplexer (void)
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+ OSL_ASSERT(mpImpl->mpEventMultiplexer.get()!=NULL);
+
+ return mpImpl->mpEventMultiplexer;
+}
+
+
+
+
+const Rectangle& ViewShellBase::getClientRectangle (void) const
+{
+ return mpImpl->maClientArea;
+}
+
+
+
+
+::boost::shared_ptr<UpdateLockManager> ViewShellBase::GetUpdateLockManager (void) const
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+ OSL_ASSERT(mpImpl->mpUpdateLockManager.get()!=NULL);
+
+ return mpImpl->mpUpdateLockManager;
+}
+
+
+
+
+::boost::shared_ptr<ToolBarManager> ViewShellBase::GetToolBarManager (void) const
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+ OSL_ASSERT(mpImpl->mpToolBarManager.get()!=NULL);
+
+ return mpImpl->mpToolBarManager;
+}
+
+
+
+
+::boost::shared_ptr<FormShellManager> ViewShellBase::GetFormShellManager (void) const
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+ OSL_ASSERT(mpImpl->mpFormShellManager.get()!=NULL);
+
+ return mpImpl->mpFormShellManager;
+}
+
+
+
+
+DrawController& ViewShellBase::GetDrawController (void) const
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+
+ return *mpImpl->mpController;
+}
+
+
+
+
+void ViewShellBase::SetViewTabBar (const ::rtl::Reference<ViewTabBar>& rViewTabBar)
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+
+ mpImpl->mpViewTabBar = rViewTabBar;
+}
+
+
+
+
+::Window* ViewShellBase::GetViewWindow (void)
+{
+ OSL_ASSERT(mpImpl.get()!=NULL);
+
+ return mpImpl->mpViewWindow.get();
+}
+
+
+::rtl::OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const ::rtl::OUString& aCmdURL )
+{
+ ::rtl::OUString aLabel;
+
+ if ( aCmdURL.getLength() > 0 ) try
+ {
+ Reference< XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+
+ Reference< XModuleManager > xModuleManager( xServiceManager->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager") ) ), UNO_QUERY_THROW );
+ Reference< XInterface > xIfac( xFrame, UNO_QUERY_THROW );
+
+ ::rtl::OUString aModuleIdentifier( xModuleManager->identify( xIfac ) );
+
+ if( aModuleIdentifier.getLength() > 0 )
+ {
+ Reference< XNameAccess > xNameAccess( xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ) ) ), UNO_QUERY );
+ if( xNameAccess.is() )
+ {
+ Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels( xNameAccess->getByName( aModuleIdentifier ), UNO_QUERY_THROW );
+ Sequence< PropertyValue > aPropSeq;
+ if( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
+ {
+ for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ if( aPropSeq[i].Name.equalsAscii( "Name" ))
+ {
+ aPropSeq[i].Value >>= aLabel;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+
+ return aLabel;
+}
+
+::rtl::OUString ViewShellBase::RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) const
+{
+ Reference< XFrame > xFrame( GetMainViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(), UNO_QUERY );
+ return ImplRetrieveLabelFromCommand( xFrame, aCmdURL );
+}
+
+
+
+//===== ViewShellBase::Implementation =========================================
+
+ViewShellBase::Implementation::Implementation (ViewShellBase& rBase)
+ : mpController(),
+ mpViewTabBar(),
+ maClientArea(),
+ mbIsClosing(false),
+ mpViewWindow(),
+ mpToolBarManager(),
+ mpViewShellManager(),
+ mpEventMultiplexer(),
+ mpUpdateLockManager(),
+ mpFormShellManager(),
+ mrBase(rBase),
+ mpPageCacheManager(slidesorter::cache::PageCacheManager::Instance())
+{
+}
+
+
+
+
+ViewShellBase::Implementation::~Implementation (void)
+{
+ mpController = NULL;
+ mpViewTabBar = NULL;
+ mpViewWindow.reset();
+ mpToolBarManager.reset();
+}
+
+
+
+
+void ViewShellBase::Implementation::LateInit (void)
+{
+ mpController = new DrawController(mrBase);
+}
+
+
+
+
+void ViewShellBase::Implementation::ProcessRestoreEditingViewSlot (void)
+{
+ ViewShell* pViewShell = mrBase.GetMainViewShell().get();
+ if (pViewShell != NULL)
+ {
+ FrameView* pFrameView = pViewShell->GetFrameView();
+ if (pFrameView != NULL)
+ {
+ // Set view shell, edit mode, and page kind.
+ pFrameView->SetViewShEditMode(
+ pFrameView->GetViewShEditModeOnLoad(),
+ pFrameView->GetPageKindOnLoad());
+ pFrameView->SetPageKind(
+ pFrameView->GetPageKindOnLoad());
+ ::boost::shared_ptr<FrameworkHelper> pHelper (FrameworkHelper::Instance(mrBase));
+ pHelper->RequestView(
+ pHelper->GetViewURL(pFrameView->GetViewShellTypeOnLoad()),
+ FrameworkHelper::msCenterPaneURL);
+ pHelper->RunOnConfigurationEvent(
+ ::rtl::OUString::createFromAscii("ConfigurationUpdateEnd"),
+ CurrentPageSetter(mrBase));
+ }
+ }
+}
+
+
+
+
+void ViewShellBase::Implementation::ShowViewTabBar (bool bShow)
+{
+ if (mpViewTabBar.is()
+ && (mpViewTabBar->GetTabControl()->IsVisible()==sal_True) != bShow)
+ {
+ mpViewTabBar->GetTabControl()->Show(bShow ? sal_True : sal_False);
+ mrBase.Rearrange();
+ }
+}
+
+
+
+
+void ViewShellBase::Implementation::ResizePixel (
+ const Point& rOrigin,
+ const Size &rSize,
+ bool bOuterResize)
+{
+ if (mbIsClosing)
+ return;
+
+ // Forward the call to both the base class and the main stacked sub
+ // shell only when main sub shell exists.
+ ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
+
+ // Set the ViewTabBar temporarily to full size so that, when asked
+ // later, it can return its true height.
+ mrBase.SetWindow (mpViewWindow.get());
+ if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
+ mpViewTabBar->GetTabControl()->SetPosSizePixel (rOrigin, rSize);
+
+ // Calculate and set the border before the controls are placed.
+ SvBorder aBorder;
+ if (pMainViewShell != NULL)
+ aBorder = pMainViewShell->GetBorder(bOuterResize);
+ aBorder += mrBase.GetBorder(bOuterResize);
+ if (mrBase.GetBorderPixel() != aBorder)
+ mrBase.SetBorderPixel(aBorder);
+
+ // Place the ViewTabBar at the top. It is part of the border.
+ SvBorder aBaseBorder;
+ if (mpViewTabBar.is() && mpViewTabBar->GetTabControl()->IsVisible())
+ {
+ aBaseBorder.Top() = mpViewTabBar->GetHeight();
+ mpViewTabBar->GetTabControl()->SetPosSizePixel(
+ rOrigin, Size(rSize.Width(),aBaseBorder.Top()));
+ }
+
+ // The view window gets the remaining space.
+ Point aViewWindowPosition (
+ rOrigin.X()+aBaseBorder.Left(),
+ rOrigin.Y()+aBaseBorder.Top());
+ Size aViewWindowSize (
+ rSize.Width() - aBaseBorder.Left() - aBaseBorder.Right(),
+ rSize.Height() - aBaseBorder.Top() - aBaseBorder.Bottom());
+ mpViewWindow->SetPosSizePixel(aViewWindowPosition, aViewWindowSize);
+
+ maClientArea = Rectangle(Point(0,0), aViewWindowSize);
+}
+
+
+
+
+void ViewShellBase::Implementation::SetPaneVisibility (
+ const SfxRequest& rRequest,
+ const ::rtl::OUString& rsPaneURL,
+ const ::rtl::OUString& rsViewURL)
+{
+ try
+ {
+ Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
+
+ const Reference< XComponentContext > xContext(
+ ::comphelper::getProcessComponentContext() );
+ Reference<XResourceId> xPaneId (ResourceId::create(
+ xContext, rsPaneURL));
+ Reference<XResourceId> xViewId (ResourceId::createWithAnchorURL(
+ xContext, rsViewURL, rsPaneURL));
+
+ // Determine the new visibility state.
+ const SfxItemSet* pArguments = rRequest.GetArgs();
+ sal_Bool bShowChildWindow;
+ sal_uInt16 nSlotId = rRequest.GetSlot();
+ if (pArguments != NULL)
+ bShowChildWindow = static_cast<const SfxBoolItem&>(
+ pArguments->Get(nSlotId)).GetValue();
+ else
+ {
+ Reference<XConfigurationController> xConfigurationController (
+ xControllerManager->getConfigurationController());
+ if ( ! xConfigurationController.is())
+ throw RuntimeException();
+ Reference<XConfiguration> xConfiguration (
+ xConfigurationController->getRequestedConfiguration());
+ if ( ! xConfiguration.is())
+ throw RuntimeException();
+
+ bShowChildWindow = ! xConfiguration->hasResource(xPaneId);
+ }
+
+ // Set the desired visibility state at the current configuration
+ // and update it accordingly.
+ Reference<XConfigurationController> xConfigurationController (
+ xControllerManager->getConfigurationController());
+ if ( ! xConfigurationController.is())
+ throw RuntimeException();
+ if (bShowChildWindow)
+ {
+ xConfigurationController->requestResourceActivation(
+ xPaneId,
+ ResourceActivationMode_ADD);
+ xConfigurationController->requestResourceActivation(
+ xViewId,
+ ResourceActivationMode_REPLACE);
+ }
+ else
+ xConfigurationController->requestResourceDeactivation(
+ xPaneId);
+ }
+ catch (const Exception &)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+}
+
+
+
+
+
+void ViewShellBase::Implementation::GetSlotState (SfxItemSet& rSet)
+{
+ try
+ {
+ // Get some frequently used values.
+ Reference<XControllerManager> xControllerManager (mrBase.GetController(), UNO_QUERY_THROW);
+ Reference<XConfigurationController> xConfigurationController (
+ xControllerManager->getConfigurationController());
+ if ( ! xConfigurationController.is())
+ throw RuntimeException();
+ Reference<XConfiguration> xConfiguration (
+ xConfigurationController->getRequestedConfiguration());
+ if ( ! xConfiguration.is())
+ throw RuntimeException();
+
+ const Reference< XComponentContext > xContext(
+ ::comphelper::getProcessComponentContext() );
+ SfxWhichIter aSetIterator (rSet);
+ sal_uInt16 nItemId (aSetIterator.FirstWhich());
+ while (nItemId > 0)
+ {
+ bool bState (false);
+ Reference<XResourceId> xResourceId;
+ try
+ {
+ switch (nItemId)
+ {
+ case SID_LEFT_PANE_IMPRESS:
+ xResourceId = ResourceId::create(
+ xContext, FrameworkHelper::msLeftImpressPaneURL);
+ break;
+
+ case SID_LEFT_PANE_DRAW:
+ xResourceId = ResourceId::create(
+ xContext, FrameworkHelper::msLeftDrawPaneURL);
+ break;
+
+ case SID_TASKPANE:
+ xResourceId = ResourceId::create(
+ xContext, FrameworkHelper::msRightPaneURL);
+ break;
+
+ case SID_NORMAL_MULTI_PANE_GUI:
+ xResourceId = ResourceId::createWithAnchorURL(
+ xContext,
+ FrameworkHelper::msImpressViewURL,
+ FrameworkHelper::msCenterPaneURL);
+ break;
+
+ case SID_SLIDE_SORTER_MULTI_PANE_GUI:
+ case SID_DIAMODE:
+ xResourceId = ResourceId::createWithAnchorURL(
+ xContext,
+ FrameworkHelper::msSlideSorterURL,
+ FrameworkHelper::msCenterPaneURL);
+ break;
+
+ case SID_OUTLINEMODE:
+ xResourceId = ResourceId::createWithAnchorURL(
+ xContext,
+ FrameworkHelper::msOutlineViewURL,
+ FrameworkHelper::msCenterPaneURL);
+ break;
+
+ case SID_HANDOUTMODE:
+ // There is only the master page mode for the handout
+ // view so ignore the master page flag.
+ xResourceId = ResourceId::createWithAnchorURL(
+ xContext,
+ FrameworkHelper::msHandoutViewURL,
+ FrameworkHelper::msCenterPaneURL);
+ break;
+
+ case SID_NOTESMODE:
+ xResourceId = ResourceId::createWithAnchorURL(
+ xContext,
+ FrameworkHelper::msNotesViewURL,
+ FrameworkHelper::msCenterPaneURL);
+ break;
+
+ default:
+ // Ignore all other items. They are not meant to be
+ // handled by us.
+ break;
+ }
+ }
+ catch (DeploymentException)
+ {
+ }
+
+ // Determine the state for the resource.
+ bState = xConfiguration->hasResource(xResourceId);
+
+ // Take the master page mode into account.
+ switch (nItemId)
+ {
+ case SID_NORMAL_MULTI_PANE_GUI:
+ case SID_NOTESMODE:
+ {
+ // Determine the master page mode.
+ ViewShell* pCenterViewShell = FrameworkHelper::Instance(mrBase)->GetViewShell(
+ FrameworkHelper::msCenterPaneURL).get();
+ bool bMasterPageMode (false);
+ if (pCenterViewShell!=NULL && pCenterViewShell->ISA(DrawViewShell))
+ if (PTR_CAST(DrawViewShell,pCenterViewShell)->GetEditMode()
+ == EM_MASTERPAGE)
+ {
+ bMasterPageMode = true;
+ }
+
+ bState &= !bMasterPageMode;
+ break;
+ }
+
+ case SID_HANDOUTMODE:
+ // There is only the master page mode for the handout
+ // view so ignore the master page flag.
+ break;
+ }
+
+ // And finally set the state.
+ rSet.Put(SfxBoolItem(nItemId, bState));
+
+ nItemId = aSetIterator.NextWhich();
+ }
+ }
+ catch (RuntimeException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+}
+
+
+
+
+void ViewShellBase::Implementation::ProcessTaskPaneSlot (SfxRequest& rRequest)
+{
+ // Set the visibility state of the toolpanel and one of its top
+ // level panels.
+ sal_Bool bShowToolPanel = sal_True;
+ toolpanel::PanelId nPanelId (
+ toolpanel::PID_UNKNOWN);
+ bool bPanelIdGiven = false;
+
+ // Extract the given arguments.
+ const SfxItemSet* pArgs = rRequest.GetArgs();
+ if (pArgs)
+ {
+ if ((pArgs->Count() == 1) || (pArgs->Count() == 2))
+ {
+ SFX_REQUEST_ARG (rRequest, pIsPanelVisible,
+ SfxBoolItem, ID_VAL_ISVISIBLE, sal_False);
+ if (pIsPanelVisible != NULL)
+ bShowToolPanel = pIsPanelVisible->GetValue();
+ }
+ if (pArgs->Count() == 2)
+ {
+ SFX_REQUEST_ARG (rRequest, pPanelId, SfxUInt32Item,
+ ID_VAL_PANEL_INDEX, sal_False);
+ if (pPanelId != NULL)
+ {
+ nPanelId = static_cast<
+ toolpanel::PanelId>(
+ pPanelId->GetValue());
+ bPanelIdGiven = true;
+ }
+ }
+ }
+
+ // Ignore the request for some combinations of panels and view
+ // shell types.
+ if (bPanelIdGiven
+ && ! (nPanelId==toolpanel::PID_LAYOUT
+ && mrBase.GetMainViewShell()!=NULL
+ && mrBase.GetMainViewShell()->GetShellType()==ViewShell::ST_OUTLINE))
+ {
+ framework::FrameworkHelper::Instance(mrBase)->RequestTaskPanel(
+ framework::FrameworkHelper::msLayoutTaskPanelURL);
+ }
+}
+
+
+} // end of namespace sd
+
+
+
+
+//===== CurrentPageSetter ===========================================
+
+namespace {
+
+CurrentPageSetter::CurrentPageSetter (ViewShellBase& rBase)
+ : mrBase(rBase)
+{
+}
+
+
+
+
+
+void CurrentPageSetter::operator() (bool)
+{
+ FrameView* pFrameView = NULL;
+
+ if (mrBase.GetMainViewShell() != NULL)
+ {
+ pFrameView = mrBase.GetMainViewShell()->GetFrameView();
+ }
+
+ if (pFrameView!=NULL)
+ {
+ try
+ {
+ // Get the current page either from the DrawPagesSupplier or the
+ // MasterPagesSupplier.
+ Any aPage;
+ if (pFrameView->GetViewShEditModeOnLoad() == EM_PAGE)
+ {
+ Reference<drawing::XDrawPagesSupplier> xPagesSupplier (
+ mrBase.GetController()->getModel(), UNO_QUERY_THROW);
+ Reference<container::XIndexAccess> xPages (
+ xPagesSupplier->getDrawPages(), UNO_QUERY_THROW);
+ aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
+ }
+ else
+ {
+ Reference<drawing::XMasterPagesSupplier> xPagesSupplier (
+ mrBase.GetController()->getModel(), UNO_QUERY_THROW);
+ Reference<container::XIndexAccess> xPages (
+ xPagesSupplier->getMasterPages(), UNO_QUERY_THROW);
+ aPage = xPages->getByIndex(pFrameView->GetSelectedPageOnLoad());
+ }
+ // Switch to the page last edited by setting the CurrentPage
+ // property.
+ Reference<beans::XPropertySet> xSet (mrBase.GetController(), UNO_QUERY_THROW);
+ xSet->setPropertyValue (String::CreateFromAscii("CurrentPage"), aPage);
+ }
+ catch (RuntimeException aException)
+ {
+ // We have not been able to set the current page at the main view.
+ // This is sad but still leaves us in a valid state. Therefore,
+ // this exception is silently ignored.
+ }
+ catch (beans::UnknownPropertyException aException)
+ {
+ DBG_ASSERT(false,"CurrentPage property unknown");
+ }
+ }
+}
+
+} // end of anonymouse namespace
+
+
+
+
+//===== FocusForwardingWindow =================================================
+
+namespace sd { namespace {
+
+FocusForwardingWindow::FocusForwardingWindow (
+ ::Window& rParentWindow,
+ ViewShellBase& rBase)
+ : ::Window(&rParentWindow, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
+ mrBase(rBase)
+{
+ OSL_TRACE("created FocusForwardingWindow at %x", this);
+}
+
+
+
+
+FocusForwardingWindow::~FocusForwardingWindow (void)
+{
+ OSL_TRACE("destroyed FocusForwardingWindow at %x", this);
+}
+
+
+
+
+void FocusForwardingWindow::KeyInput (const KeyEvent& rKEvt)
+{
+ ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
+ if (pViewShell.get() != NULL)
+ {
+ ::Window* pWindow = pViewShell->GetActiveWindow();
+ if (pWindow != NULL)
+ {
+ // Forward the focus so that the window is called directly the
+ // next time.
+ pWindow->GrabFocus();
+ // Forward the key press as well.
+ pWindow->KeyInput(rKEvt);
+ }
+ }
+}
+
+
+
+
+void FocusForwardingWindow::Command (const CommandEvent& rEvent)
+{
+ ::boost::shared_ptr<ViewShell> pViewShell = mrBase.GetMainViewShell();
+ if (pViewShell.get() != NULL)
+ {
+ ::Window* pWindow = pViewShell->GetActiveWindow();
+ if (pWindow != NULL)
+ {
+ pWindow->Command(rEvent);
+ }
+ }
+}
+
+
+} // end of anonymouse namespace
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/ViewShellHint.cxx b/sd/source/ui/view/ViewShellHint.cxx
new file mode 100644
index 000000000000..e23cc8964d23
--- /dev/null
+++ b/sd/source/ui/view/ViewShellHint.cxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * 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 "ViewShellHint.hxx"
+
+namespace sd {
+
+TYPEINIT1(ViewShellHint, SfxHint);
+
+ViewShellHint::ViewShellHint (HintId eHintId)
+ : SfxHint(),
+ meHintId(eHintId)
+{
+}
+
+
+
+
+ViewShellHint::HintId ViewShellHint::GetHintId (void) const
+{
+ return meHintId;
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/ViewShellImplementation.cxx b/sd/source/ui/view/ViewShellImplementation.cxx
new file mode 100755
index 000000000000..613aff9fd36c
--- /dev/null
+++ b/sd/source/ui/view/ViewShellImplementation.cxx
@@ -0,0 +1,449 @@
+/*************************************************************************
+ *
+ * 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 "ViewShellImplementation.hxx"
+
+#include "sdpage.hxx"
+#include "drawdoc.hxx"
+#include "sdresid.hxx"
+#include "glob.hrc"
+#include "app.hrc"
+#include "strings.hrc"
+#include "strings.hrc"
+#include "helpids.h"
+#include "sdattr.hxx"
+#include "sdabstdlg.hxx"
+#include "unmodpg.hxx"
+#include "Window.hxx"
+#include "optsitem.hxx"
+#include "DrawDocShell.hxx"
+#include "DrawController.hxx"
+#include "FactoryIds.hxx"
+#include "slideshow.hxx"
+#include "ViewShellBase.hxx"
+#include "FrameView.hxx"
+#include "DrawViewShell.hxx"
+#include "ViewShellHint.hxx"
+#include "taskpane/PanelId.hxx"
+#include "framework/FrameworkHelper.hxx"
+
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <svl/aeitem.hxx>
+#include <svx/imapdlg.hxx>
+#include <vcl/msgbox.hxx>
+#include <basic/sbstar.hxx>
+#include "undo/undoobjects.hxx"
+
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+using ::sd::framework::FrameworkHelper;
+
+namespace sd {
+
+ViewShell::Implementation::Implementation (ViewShell& rViewShell)
+ : mbIsShowingUIControls(false),
+ mbIsMainViewShell(false),
+ mbIsInitialized(false),
+ mbArrangeActive(false),
+ mpSubShellFactory(),
+ mpUpdateLockForMouse(),
+ mrViewShell(rViewShell)
+{
+}
+
+
+
+
+ViewShell::Implementation::~Implementation (void)
+{
+ if ( ! mpUpdateLockForMouse.expired())
+ {
+ ::boost::shared_ptr<ToolBarManagerLock> pLock(mpUpdateLockForMouse);
+ if (pLock.get() != NULL)
+ {
+ // Force the ToolBarManagerLock to be released even when the
+ // IsUICaptured() returns <TRUE/>.
+ pLock->Release(true);
+ }
+ }
+}
+
+
+
+
+void ViewShell::Implementation::ProcessModifyPageSlot (
+ SfxRequest& rRequest,
+ SdPage* pCurrentPage,
+ PageKind ePageKind)
+{
+ SdDrawDocument* pDocument = mrViewShell.GetDoc();
+ SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
+ sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
+ sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
+ SetOfByte aVisibleLayers;
+ sal_Bool bHandoutMode = sal_False;
+ SdPage* pHandoutMPage = NULL;
+ String aNewName;
+
+ // #95981#
+ String aOldName;
+
+ AutoLayout aNewAutoLayout;
+
+ sal_Bool bBVisible;
+ sal_Bool bBObjsVisible;
+ const SfxItemSet* pArgs = rRequest.GetArgs();
+
+ if (pCurrentPage != NULL && pCurrentPage->TRG_HasMasterPage())
+ aVisibleLayers = pCurrentPage->TRG_GetMasterPageVisibleLayers();
+ else
+ aVisibleLayers.SetAll();
+
+ do
+ {
+ if (pCurrentPage == NULL)
+ break;
+
+ if (!pArgs || pArgs->Count() == 1 || pArgs->Count() == 2 )
+ {
+ if (pArgs && pArgs->Count() == 2)
+ {
+ // We have been called with a request that contains two
+ // arguments. One was used as preselected layout in a
+ // dialog. We could select that layout in the
+ // layout panel instead.
+ /*
+ SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
+ eNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue
+ ();
+ */
+ }
+
+ // Make the layout menu visible in the tool pane.
+ SfxBoolItem aMakeToolPaneVisible (ID_VAL_ISVISIBLE, sal_True);
+ SfxUInt32Item aPanelId (ID_VAL_PANEL_INDEX,
+ ::sd::toolpanel::PID_LAYOUT);
+ SfxViewFrame* pFrame = mrViewShell.GetViewFrame();
+ if (pFrame!=NULL && pFrame->GetDispatcher()!=NULL)
+ {
+ pFrame->GetDispatcher()->Execute (
+ SID_SHOW_TOOL_PANEL,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aMakeToolPaneVisible,
+ &aPanelId,
+ NULL);
+ }
+ else
+ {
+ DBG_ASSERT(pFrame!=NULL && pFrame->GetDispatcher()!=NULL,
+ "ViewShell::Implementation::ProcessModifyPageSlot(): can not get dispatcher");
+ }
+
+ // We have activated a non-modal control in the task pane.
+ // Because it does not return anything we can not do anything
+ // more right now and have to exit here.
+ break;
+ }
+ else if (pArgs->Count() == 4)
+ {
+ SFX_REQUEST_ARG (rRequest, pNewName, SfxStringItem, ID_VAL_PAGENAME, sal_False);
+ SFX_REQUEST_ARG (rRequest, pNewAutoLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
+ SFX_REQUEST_ARG (rRequest, pBVisible, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False);
+ SFX_REQUEST_ARG (rRequest, pBObjsVisible, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False);
+ AutoLayout aLayout ((AutoLayout)pNewAutoLayout->GetValue ());
+ if (aLayout >= AUTOLAYOUT__START
+ && aLayout < AUTOLAYOUT__END)
+ {
+ aNewName = pNewName->GetValue ();
+ aNewAutoLayout = (AutoLayout) pNewAutoLayout->GetValue ();
+ bBVisible = pBVisible->GetValue ();
+ bBObjsVisible = pBObjsVisible->GetValue ();
+ }
+ else
+ {
+ StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+ rRequest.Ignore ();
+ break;
+ }
+ if (ePageKind == PK_HANDOUT)
+ {
+ bHandoutMode = sal_True;
+ pHandoutMPage = pDocument->GetMasterSdPage(0, PK_HANDOUT);
+ }
+ }
+ else
+ {
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ rRequest.Ignore ();
+ break;
+ }
+
+ SdPage* pUndoPage =
+ bHandoutMode ? pHandoutMPage : pCurrentPage;
+
+ ::svl::IUndoManager* pUndoManager = mrViewShell.GetDocSh()->GetUndoManager();
+ DBG_ASSERT(pUndoManager, "No UNDO MANAGER ?!?");
+
+ if( pUndoManager )
+ {
+ String aComment( SdResId(STR_UNDO_MODIFY_PAGE) );
+ pUndoManager->EnterListAction(aComment, aComment);
+ ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
+ pDocument, pUndoPage, aNewName, aNewAutoLayout, bBVisible, bBObjsVisible);
+ pUndoManager->AddUndoAction(pAction);
+
+ // Clear the selection because the selectec object may be removed as
+ // a result of the ssignment of the layout.
+ mrViewShell.GetDrawView()->UnmarkAll();
+
+ if (!bHandoutMode)
+ {
+ if (pCurrentPage->GetName() != aNewName)
+ {
+ pCurrentPage->SetName(aNewName);
+
+ if (ePageKind == PK_STANDARD)
+ {
+ sal_uInt16 nPage = (pCurrentPage->GetPageNum()-1) / 2;
+ SdPage* pNotesPage = pDocument->GetSdPage(nPage, PK_NOTES);
+ if (pNotesPage != NULL)
+ pNotesPage->SetName(aNewName);
+ }
+ }
+
+ pCurrentPage->SetAutoLayout(aNewAutoLayout, sal_True);
+
+ aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
+ aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
+ aVisibleLayers.Set(aBckgrnd, bBVisible);
+ aVisibleLayers.Set(aBckgrndObj, bBObjsVisible);
+ pCurrentPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
+ }
+ else
+ {
+ pHandoutMPage->SetAutoLayout(aNewAutoLayout, sal_True);
+ }
+
+ mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+
+ sal_Bool bSetModified = sal_True;
+
+ if (pArgs && pArgs->Count() == 1)
+ {
+ bSetModified = (sal_Bool) ((SfxBoolItem&) pArgs->Get(SID_MODIFYPAGE)).GetValue();
+ }
+
+ pUndoManager->AddUndoAction( new UndoAutoLayoutPosAndSize( *pUndoPage ) );
+ pUndoManager->LeaveListAction();
+
+ pDocument->SetChanged(bSetModified);
+ }
+ }
+ while (false);
+
+ mrViewShell.Cancel();
+ rRequest.Done ();
+}
+
+void ViewShell::Implementation::AssignLayout ( SfxRequest& rRequest, PageKind ePageKind )
+{
+ const SfxUInt32Item* pWhatPage = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATPAGE, sal_False, TYPE(SfxUInt32Item) ) );
+ const SfxUInt32Item* pWhatLayout = static_cast< const SfxUInt32Item* > ( rRequest.GetArg( ID_VAL_WHATLAYOUT, sal_False, TYPE(SfxUInt32Item) ) );
+
+ SdDrawDocument* pDocument = mrViewShell.GetDoc();
+ if( !pDocument )
+ return;
+
+ SdPage* pPage = 0;
+ if( pWhatPage )
+ {
+ pPage = pDocument->GetSdPage(static_cast<sal_uInt16>(pWhatPage->GetValue()), ePageKind);
+ }
+
+ if( pPage == 0 )
+ pPage = mrViewShell.getCurrentPage();
+
+ if( pPage )
+ {
+ AutoLayout eLayout = pPage->GetAutoLayout();
+
+ if( pWhatLayout )
+ eLayout = static_cast< AutoLayout >( pWhatLayout->GetValue() );
+
+ // Transform the given request into the four argument form that is
+ // understood by ProcessModifyPageSlot().
+ SdrLayerAdmin& rLayerAdmin (mrViewShell.GetViewShellBase().GetDocument()->GetLayerAdmin());
+ sal_uInt8 aBackground (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False));
+ sal_uInt8 aBackgroundObject (rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False));
+
+ SetOfByte aVisibleLayers;
+
+ if( pPage->GetPageKind() == PK_HANDOUT )
+ aVisibleLayers.SetAll();
+ else
+ aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+
+ SfxRequest aRequest (mrViewShell.GetViewShellBase().GetViewFrame(), SID_MODIFYPAGE);
+ aRequest.AppendItem(SfxStringItem (ID_VAL_PAGENAME, pPage->GetName()));
+ aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, eLayout));
+ aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground)));
+ aRequest.AppendItem(SfxBoolItem(ID_VAL_ISPAGEOBJ, aVisibleLayers.IsSet(aBackgroundObject)));
+
+ // Forward the call with the new arguments.
+ ProcessModifyPageSlot( aRequest, pPage, pPage->GetPageKind());
+ }
+}
+
+
+
+
+sal_uInt16 ViewShell::Implementation::GetViewId (void)
+{
+ switch (mrViewShell.GetShellType())
+ {
+ case ViewShell::ST_IMPRESS:
+ case ViewShell::ST_NOTES:
+ case ViewShell::ST_HANDOUT:
+ return IMPRESS_FACTORY_ID;
+
+ case ViewShell::ST_DRAW:
+ return DRAW_FACTORY_ID;
+
+ case ViewShell::ST_OUTLINE:
+ return OUTLINE_FACTORY_ID;
+
+ case ViewShell::ST_SLIDE_SORTER:
+ return SLIDE_SORTER_FACTORY_ID;
+
+ case ViewShell::ST_PRESENTATION:
+ return PRESENTATION_FACTORY_ID;
+
+ // Since we have to return a view id for every possible shell type
+ // and there is not (yet) a proper ViewShellBase sub class for the
+ // remaining types we chose the Impress factory as a fall back.
+ case ViewShell::ST_TASK_PANE:
+ case ViewShell::ST_NONE:
+ default:
+ return IMPRESS_FACTORY_ID;
+ }
+}
+
+
+
+
+SvxIMapDlg* ViewShell::Implementation::GetImageMapDialog (void)
+{
+ SvxIMapDlg* pDialog = NULL;
+ SfxChildWindow* pChildWindow = SfxViewFrame::Current()->GetChildWindow(
+ SvxIMapDlgChildWindow::GetChildWindowId());
+ if (pChildWindow != NULL)
+ pDialog = dynamic_cast<SvxIMapDlg*>(pChildWindow->GetWindow());
+ return pDialog;
+}
+
+
+
+//===== ToolBarManagerLock ====================================================
+
+class ViewShell::Implementation::ToolBarManagerLock::Deleter { public:
+ void operator() (ToolBarManagerLock* pObject) { delete pObject; }
+};
+
+::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock>
+ ViewShell::Implementation::ToolBarManagerLock::Create (
+ const ::boost::shared_ptr<ToolBarManager>& rpManager)
+{
+ ::boost::shared_ptr<ToolBarManagerLock> pLock (
+ new ViewShell::Implementation::ToolBarManagerLock(rpManager),
+ ViewShell::Implementation::ToolBarManagerLock::Deleter());
+ pLock->mpSelf = pLock;
+ return pLock;
+}
+
+
+
+
+ViewShell::Implementation::ToolBarManagerLock::ToolBarManagerLock (
+ const ::boost::shared_ptr<ToolBarManager>& rpManager)
+ : mpLock(new ToolBarManager::UpdateLock(rpManager)),
+ maTimer()
+{
+ // Start a timer that will unlock the ToolBarManager update lock when
+ // that is not done explicitly by calling Release().
+ maTimer.SetTimeoutHdl(LINK(this,ToolBarManagerLock,TimeoutCallback));
+ maTimer.SetTimeout(100);
+ maTimer.Start();
+}
+
+
+
+
+IMPL_LINK(ViewShell::Implementation::ToolBarManagerLock,TimeoutCallback,Timer*,EMPTYARG)
+{
+ // If possible then release the lock now. Otherwise start the timer
+ // and try again later.
+ if (Application::IsUICaptured())
+ {
+ maTimer.Start();
+ }
+ else
+ {
+ mpSelf.reset();
+ }
+ return 0;
+}
+
+
+
+
+void ViewShell::Implementation::ToolBarManagerLock::Release (bool bForce)
+{
+ // If possible then release the lock now. Otherwise try again when the
+ // timer expires.
+ if (bForce || ! Application::IsUICaptured())
+ {
+ mpSelf.reset();
+ }
+}
+
+
+
+
+ViewShell::Implementation::ToolBarManagerLock::~ToolBarManagerLock (void)
+{
+ mpLock.reset();
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/ViewShellManager.cxx b/sd/source/ui/view/ViewShellManager.cxx
new file mode 100755
index 000000000000..2df075662eb1
--- /dev/null
+++ b/sd/source/ui/view/ViewShellManager.cxx
@@ -0,0 +1,1467 @@
+/*************************************************************************
+ *
+ * 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 "ViewShellManager.hxx"
+#include "ViewShell.hxx"
+#include "ViewShellBase.hxx"
+#include "Window.hxx"
+#include "DrawDocShell.hxx"
+#include "FormShellManager.hxx"
+
+#include <sfx2/dispatch.hxx>
+#include <svx/svxids.hrc>
+#include <svx/fmshell.hxx>
+
+#include <hash_map>
+
+#undef VERBOSE
+//#define VERBOSE 2
+
+namespace sd {
+
+namespace {
+
+/** The ShellDescriptor class is used to shells together with their ids and
+ the factory that was used to create the shell.
+
+ The shell pointer may be NULL. In that case the shell is created on
+ demand by a factory.
+
+ The factory pointer may be NULL. In that case the shell pointer is
+ given to the ViewShellManager.
+
+ Shell pointer and factory pointer can but should not be NULL at the same
+ time.
+*/
+class ShellDescriptor {
+public:
+ SfxShell* mpShell;
+ ShellId mnId;
+ ViewShellManager::SharedShellFactory mpFactory;
+ ShellDescriptor ();
+ ShellDescriptor (SfxShell* pShell, ShellId nId);
+ ShellDescriptor (const ShellDescriptor& rDescriptor);
+ ShellDescriptor& operator= (const ShellDescriptor& rDescriptor);
+ bool IsMainViewShell (void) const;
+ ::Window* GetWindow (void) const;
+};
+
+
+
+
+/** This functor can be used to search for a shell in an STL container when the
+ shell pointer is given.
+*/
+class IsShell : public ::std::unary_function<ShellDescriptor,bool>
+{
+public:
+ IsShell (const SfxShell* pShell) : mpShell(pShell) {}
+ bool operator() (const ShellDescriptor& rDescriptor)
+ { return rDescriptor.mpShell == mpShell; }
+private:
+ const SfxShell* mpShell;
+};
+
+
+
+
+/** This functor can be used to search for a shell in an STL container when the
+ id of the shell is given.
+*/
+class IsId : public ::std::unary_function<ShellDescriptor,bool>
+{
+public:
+ IsId (ShellId nId) : mnId(nId) {}
+ bool operator() (const ShellDescriptor& rDescriptor)
+ { return rDescriptor.mnId == mnId; }
+private:
+ ShellId mnId;
+};
+
+} // end of anonymous namespace
+
+
+
+
+class ViewShellManager::Implementation
+{
+public:
+ Implementation (
+ ViewShellManager& rManager,
+ ViewShellBase& rBase);
+ ~Implementation (void);
+
+ void AddShellFactory (
+ const SfxShell* pViewShell,
+ const SharedShellFactory& rpFactory);
+ void RemoveShellFactory (
+ const SfxShell* pViewShell,
+ const SharedShellFactory& rpFactory);
+ void ActivateViewShell (
+ ViewShell* pViewShell);
+ void DeactivateViewShell (const ViewShell& rShell);
+ void ActivateShell (SfxShell& rShell);
+ void DeactivateShell (const SfxShell& rShell);
+ void ActivateShell (const ShellDescriptor& rDescriptor);
+ void SetFormShell (const ViewShell* pViewShell, FmFormShell* pFormShell, bool bAbove);
+ void ActivateSubShell (const SfxShell& rParentShell, ShellId nId);
+ void DeactivateSubShell (const SfxShell& rParentShell, ShellId nId);
+ void MoveSubShellToTop (const SfxShell& rParentShell, ShellId nId);
+ void MoveToTop (const SfxShell& rParentShell);
+ SfxShell* GetShell (ShellId nId) const;
+ SfxShell* GetTopShell (void) const;
+ void Shutdown (void);
+ void InvalidateAllSubShells (const SfxShell* pParentShell);
+
+ /** Remove all shells from the SFX stack above and including the given
+ shell.
+ */
+ void TakeShellsFromStack (const SfxShell* pShell);
+
+ class UpdateLock
+ {
+ public:
+ UpdateLock (Implementation& rImpl) : mrImpl(rImpl) {mrImpl.LockUpdate();}
+ ~UpdateLock (void) {mrImpl.UnlockUpdate();};
+ private:
+ Implementation& mrImpl;
+ };
+
+
+
+ /** Prevent updates of the shell stack. While the sub shell manager is
+ locked it will update its internal data structures but not alter the
+ shell stack. Use this method when there are several modifications
+ to the shell stack to prevent multiple rebuilds of the shell stack
+ and resulting broadcasts.
+ */
+ void LockUpdate (void);
+
+ /** Allow updates of the shell stack. This method has to be called the
+ same number of times as LockUpdate() to really allow a rebuild of
+ the shell stack.
+ */
+ void UnlockUpdate (void);
+
+private:
+ ViewShellBase& mrBase;
+ mutable ::osl::Mutex maMutex;
+
+ class ShellHash{public: size_t operator()(const SfxShell* p) const { return (size_t)p;} };
+ typedef ::std::hash_multimap<const SfxShell*,SharedShellFactory,ShellHash>
+ FactoryList;
+ FactoryList maShellFactories;
+
+ /** List of the active view shells. In order to create gather all shells
+ to put on the shell stack each view shell in this list is asked for
+ its sub-shells (typically toolbars).
+ */
+ typedef ::std::list<ShellDescriptor> ActiveShellList;
+ ActiveShellList maActiveViewShells;
+
+ typedef ::std::list<ShellDescriptor> SubShellSubList;
+ typedef ::std::hash_map<const SfxShell*,SubShellSubList,ShellHash> SubShellList;
+ SubShellList maActiveSubShells;
+
+ /** In this member we remember what shells we have pushed on the shell
+ stack.
+ */
+ typedef ::std::vector<SfxShell*> ShellStack;
+
+ int mnUpdateLockCount;
+
+ /** When this flag is set then the main view shell is always kept at the
+ top of the shell stack.
+ */
+ bool mbKeepMainViewShellOnTop;
+
+ /** The UpdateShellStack() method can be called recursively. This flag
+ is used to communicate between different levels of invocation: if
+ the stack has been updated in an inner call the outer call can (has
+ to) stop and return immediately.
+ */
+ bool mbShellStackIsUpToDate;
+
+ SfxShell* mpFormShell;
+ const ViewShell* mpFormShellParent;
+ bool mbFormShellAboveParent;
+
+ SfxShell* mpTopShell;
+
+ void GatherActiveShells (ShellStack& rShellList);
+
+ void UpdateShellStack (void);
+
+ void CreateShells (void);
+
+ /** This method rebuilds the stack of shells that are stacked upon the
+ view shell base.
+ */
+ void CreateTargetStack (ShellStack& rStack) const;
+
+ DECL_LINK(WindowEventHandler, VclWindowEvent*);
+
+#ifdef VERBOSE
+ void DumpShellStack (const ShellStack& rStack);
+ void DumpSfxShellStack (void);
+#endif
+
+ /** To be called before a shell is taken fom the SFX shell stack. This
+ method deactivates an active text editing to avoid problems with
+ undo managers.
+ Afterwards the Deactivate() of the shell is called.
+ */
+ void Deactivate (SfxShell* pShell);
+
+ ShellDescriptor CreateSubShell (
+ SfxShell* pShell,
+ ShellId nShellId,
+ ::Window* pParentWindow,
+ FrameView* pFrameView);
+ void DestroyViewShell (const ShellDescriptor& rDescriptor);
+ void DestroySubShell (
+ const SfxShell& rViewShell,
+ const ShellDescriptor& rDescriptor);
+};
+
+
+
+
+//===== ViewShellManager ======================================================
+
+ViewShellManager::ViewShellManager (ViewShellBase& rBase)
+ : mpImpl(new Implementation(*this,rBase)),
+ mbValid(true)
+{
+}
+
+
+
+
+ViewShellManager::~ViewShellManager (void)
+{
+}
+
+
+
+
+void ViewShellManager::AddSubShellFactory (
+ ViewShell* pViewShell,
+ const SharedShellFactory& rpFactory)
+{
+ if (mbValid)
+ mpImpl->AddShellFactory(pViewShell, rpFactory);
+}
+
+
+
+
+void ViewShellManager::RemoveSubShellFactory (
+ ViewShell* pViewShell,
+ const SharedShellFactory& rpFactory)
+{
+ if (mbValid)
+ mpImpl->RemoveShellFactory(pViewShell, rpFactory);
+}
+
+
+
+
+void ViewShellManager::ActivateViewShell (ViewShell* pViewShell)
+{
+ if (mbValid)
+ return mpImpl->ActivateViewShell(pViewShell);
+}
+
+
+
+
+void ViewShellManager::DeactivateViewShell (const ViewShell* pShell)
+{
+ if (mbValid && pShell!=NULL)
+ mpImpl->DeactivateViewShell(*pShell);
+}
+
+
+
+
+void ViewShellManager::MoveSubShellToTop (
+ const ViewShell& rParentShell,
+ ShellId nId)
+{
+ if (mbValid)
+ mpImpl->MoveSubShellToTop(rParentShell, nId);
+}
+
+
+
+
+void ViewShellManager::SetFormShell (
+ const ViewShell* pParentShell,
+ FmFormShell* pFormShell,
+ bool bAbove)
+{
+ if (mbValid)
+ mpImpl->SetFormShell(pParentShell,pFormShell,bAbove);
+}
+
+
+
+
+void ViewShellManager::ActivateSubShell (const ViewShell& rViewShell, ShellId nId)
+{
+ if (mbValid)
+ mpImpl->ActivateSubShell(rViewShell,nId);
+}
+
+
+
+
+void ViewShellManager::DeactivateSubShell (const ViewShell& rViewShell, ShellId nId)
+{
+ if (mbValid)
+ mpImpl->DeactivateSubShell(rViewShell,nId);
+}
+
+
+
+
+void ViewShellManager::InvalidateAllSubShells (ViewShell* pViewShell)
+{
+ if (mbValid)
+ mpImpl->InvalidateAllSubShells(pViewShell);
+}
+
+
+
+
+void ViewShellManager::ActivateShell (SfxShell* pShell)
+{
+ if (mbValid && pShell!=NULL)
+ mpImpl->ActivateShell(*pShell);
+}
+
+
+
+
+void ViewShellManager::DeactivateShell (const SfxShell* pShell)
+{
+ if (mbValid && pShell!=NULL)
+ mpImpl->DeactivateShell(*pShell);
+}
+
+
+
+
+void ViewShellManager::MoveToTop (const ViewShell& rParentShell)
+{
+ if (mbValid)
+ mpImpl->MoveToTop(rParentShell);
+}
+
+
+
+
+SfxShell* ViewShellManager::GetShell (ShellId nId) const
+{
+ if (mbValid)
+ return mpImpl->GetShell(nId);
+ else
+ return NULL;
+}
+
+
+
+
+SfxShell* ViewShellManager::GetTopShell (void) const
+{
+ if (mbValid)
+ return mpImpl->GetTopShell();
+ else
+ return NULL;
+}
+
+
+
+
+void ViewShellManager::Shutdown (void)
+{
+ if (mbValid)
+ {
+ mpImpl->Shutdown();
+ mbValid = false;
+ }
+}
+
+
+
+void ViewShellManager::LockUpdate (void)
+{
+ mpImpl->LockUpdate();
+}
+
+
+
+
+void ViewShellManager::UnlockUpdate (void)
+{
+ mpImpl->UnlockUpdate();
+}
+
+
+
+
+//===== ViewShellManager::Implementation ======================================
+
+ViewShellManager::Implementation::Implementation (
+ ViewShellManager& rManager,
+ ViewShellBase& rBase)
+ : mrBase(rBase),
+ maMutex(),
+ maShellFactories(),
+ maActiveViewShells(),
+ mnUpdateLockCount(0),
+ mbKeepMainViewShellOnTop(false),
+ mbShellStackIsUpToDate(true),
+ mpFormShell(NULL),
+ mpFormShellParent(NULL),
+ mbFormShellAboveParent(true),
+ mpTopShell(NULL)
+{
+ (void)rManager;
+}
+
+
+
+
+ViewShellManager::Implementation::~Implementation (void)
+{
+ Shutdown();
+}
+
+
+
+
+void ViewShellManager::Implementation::AddShellFactory (
+ const SfxShell* pViewShell,
+ const SharedShellFactory& rpFactory)
+{
+ bool bAlreadyAdded (false);
+
+ // Check that the given factory has not already been added.
+ ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange(
+ maShellFactories.equal_range(pViewShell));
+ for (FactoryList::const_iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory)
+ if (iFactory->second == rpFactory)
+ {
+ bAlreadyAdded = true;
+ break;
+ }
+
+ // Add the factory if it is not already present.
+ if ( ! bAlreadyAdded)
+ maShellFactories.insert(FactoryList::value_type(pViewShell, rpFactory));
+}
+
+
+
+
+void ViewShellManager::Implementation::RemoveShellFactory (
+ const SfxShell* pViewShell,
+ const SharedShellFactory& rpFactory)
+{
+ ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange(
+ maShellFactories.equal_range(pViewShell));
+ for (FactoryList::iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory)
+ if (iFactory->second == rpFactory)
+ {
+ maShellFactories.erase(iFactory);
+ break;
+ }
+}
+
+
+
+
+void ViewShellManager::Implementation::ActivateViewShell (ViewShell* pViewShell)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ ShellDescriptor aResult;
+ aResult.mpShell = pViewShell;
+
+ // Register as window listener so that the shells of the current
+ // window can be moved to the top of the shell stack.
+ if (aResult.mpShell != NULL)
+ {
+ ::Window* pWindow = aResult.GetWindow();
+ if (pWindow != NULL)
+ pWindow->AddEventListener(
+ LINK(this, ViewShellManager::Implementation, WindowEventHandler));
+ else
+ {
+ DBG_ASSERT(false,
+ "ViewShellManager::ActivateViewShell: "
+ "new view shell has no active window");
+ }
+ }
+
+ ActivateShell(aResult);
+}
+
+
+
+
+void ViewShellManager::Implementation::DeactivateViewShell (const ViewShell& rShell)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ ActiveShellList::iterator iShell (::std::find_if (
+ maActiveViewShells.begin(),
+ maActiveViewShells.end(),
+ IsShell(&rShell)));
+ if (iShell != maActiveViewShells.end())
+ {
+ UpdateLock aLocker (*this);
+
+ ShellDescriptor aDescriptor(*iShell);
+ mrBase.GetDocShell()->Disconnect(dynamic_cast<ViewShell*>(aDescriptor.mpShell));
+ maActiveViewShells.erase(iShell);
+ TakeShellsFromStack(aDescriptor.mpShell);
+
+ // Deactivate sub shells.
+ SubShellList::iterator iList (maActiveSubShells.find(&rShell));
+ if (iList != maActiveSubShells.end())
+ {
+ SubShellSubList& rList (iList->second);
+ while ( ! rList.empty())
+ DeactivateSubShell(rShell, rList.front().mnId);
+ }
+
+ DestroyViewShell(aDescriptor);
+ }
+}
+
+
+
+
+void ViewShellManager::Implementation::ActivateShell (SfxShell& rShell)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ // Create a new shell or recycle on in the cache.
+ ShellDescriptor aDescriptor;
+ aDescriptor.mpShell = &rShell;
+
+ ActivateShell(aDescriptor);
+}
+
+
+
+
+void ViewShellManager::Implementation::ActivateShell (const ShellDescriptor& rDescriptor)
+{
+ // Put shell on top of the active view shells.
+ if (rDescriptor.mpShell != NULL)
+ {
+ // Determine where to put the view shell on the stack. By default
+ // it is put on top of the stack. When the view shell of the center
+ // pane is to be kept top most and the new view shell is not
+ // displayed in the center pane then it is inserted at the position
+ // one below the top.
+ ActiveShellList::iterator iInsertPosition (maActiveViewShells.begin());
+ if (iInsertPosition != maActiveViewShells.end()
+ && mbKeepMainViewShellOnTop
+ && ! rDescriptor.IsMainViewShell()
+ && iInsertPosition->IsMainViewShell())
+ {
+ ++iInsertPosition;
+ }
+ maActiveViewShells.insert(
+ iInsertPosition,
+ rDescriptor);
+ }
+}
+
+
+
+
+void ViewShellManager::Implementation::DeactivateShell (const SfxShell& rShell)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ ActiveShellList::iterator iShell (::std::find_if (
+ maActiveViewShells.begin(),
+ maActiveViewShells.end(),
+ IsShell(&rShell)));
+ if (iShell != maActiveViewShells.end())
+ {
+ UpdateLock aLocker (*this);
+
+ ShellDescriptor aDescriptor(*iShell);
+ mrBase.GetDocShell()->Disconnect(dynamic_cast<ViewShell*>(aDescriptor.mpShell));
+ maActiveViewShells.erase(iShell);
+ TakeShellsFromStack(aDescriptor.mpShell);
+
+ // Deactivate sub shells.
+ SubShellList::iterator iList (maActiveSubShells.find(&rShell));
+ if (iList != maActiveSubShells.end())
+ {
+ SubShellSubList& rList (iList->second);
+ while ( ! rList.empty())
+ DeactivateSubShell(rShell, rList.front().mnId);
+ }
+
+ DestroyViewShell(aDescriptor);
+ }
+}
+
+
+
+
+void ViewShellManager::Implementation::ActivateSubShell (
+ const SfxShell& rParentShell,
+ ShellId nId)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ do
+ {
+ // Check that the given view shell is active.
+ ActiveShellList::iterator iShell (::std::find_if (
+ maActiveViewShells.begin(),
+ maActiveViewShells.end(),
+ IsShell(&rParentShell)));
+ if (iShell == maActiveViewShells.end())
+ break;
+
+ // Create the sub shell list if it does not yet exist.
+ SubShellList::iterator iList (maActiveSubShells.find(&rParentShell));
+ if (iList == maActiveSubShells.end())
+ iList = maActiveSubShells.insert(
+ SubShellList::value_type(&rParentShell,SubShellSubList())).first;
+
+ // Do not activate an object bar that is already active. Requesting
+ // this is not exactly an error but may be an indication of one.
+ SubShellSubList& rList (iList->second);
+ if (::std::find_if(rList.begin(),rList.end(), IsId(nId)) != rList.end())
+ break;
+
+ // Add just the id of the sub shell. The actual shell is created
+ // later in CreateShells().
+ UpdateLock aLock (*this);
+ rList.push_back(ShellDescriptor(NULL, nId));
+ }
+ while (false);
+}
+
+
+
+
+void ViewShellManager::Implementation::DeactivateSubShell (
+ const SfxShell& rParentShell,
+ ShellId nId)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ do
+ {
+ // Check that the given view shell is active.
+ SubShellList::iterator iList (maActiveSubShells.find(&rParentShell));
+ if (iList == maActiveSubShells.end())
+ break;
+
+ // Look up the sub shell.
+ SubShellSubList& rList (iList->second);
+ SubShellSubList::iterator iShell (
+ ::std::find_if(rList.begin(),rList.end(), IsId(nId)));
+ if (iShell == rList.end())
+ break;
+ SfxShell* pShell = iShell->mpShell;
+ if (pShell == NULL)
+ break;
+
+ UpdateLock aLock (*this);
+
+ ShellDescriptor aDescriptor(*iShell);
+ // Remove the sub shell from both the internal structure as well as the
+ // SFX shell stack above and including the sub shell.
+ rList.erase(iShell);
+ TakeShellsFromStack(pShell);
+
+ DestroySubShell(rParentShell, aDescriptor);
+ }
+ while (false);
+}
+
+
+
+
+void ViewShellManager::Implementation::MoveSubShellToTop (
+ const SfxShell& rParentShell,
+ ShellId nId)
+{
+ SubShellList::iterator iList (maActiveSubShells.find(&rParentShell));
+ if (iList != maActiveSubShells.end())
+ {
+ // Look up the sub shell.
+ SubShellSubList& rList (iList->second);
+ SubShellSubList::iterator iShell (
+ ::std::find_if(rList.begin(),rList.end(), IsId(nId)));
+ if (iShell!=rList.end() && iShell!=rList.begin())
+ {
+ SubShellSubList::value_type aEntry (*iShell);
+ rList.erase(iShell);
+ rList.push_front(aEntry);
+ }
+ }
+ else
+ {
+ // Ignore this call when there are no sub shells for the given
+ // parent shell. We could remember the sub shell to move to the top
+ // but we do not. Do call this method at a later time instead.
+ }
+}
+
+
+
+void ViewShellManager::Implementation::MoveToTop (const SfxShell& rShell)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ // Check that we have access to a dispatcher. If not, then we are
+ // (probably) called while the view shell is still being created or
+ // initialized. Without dispatcher we can not rebuild the shell stack
+ // to move the requested shell to the top. So return right away instead
+ // of making a mess without being able to clean up afterwards.
+ if (mrBase.GetDispatcher() == NULL)
+ return;
+
+ ActiveShellList::iterator iShell (::std::find_if (
+ maActiveViewShells.begin(),
+ maActiveViewShells.end(),
+ IsShell(&rShell)));
+ bool bMove = true;
+ if (iShell != maActiveViewShells.end())
+ {
+ // Is the shell already at the top of the stack? We have to keep
+ // the case in mind that mbKeepMainViewShellOnTop is true. Shells
+ // that are not the main view shell are placed on the second-to-top
+ // position in this case.
+ if (iShell == maActiveViewShells.begin()
+ && (iShell->IsMainViewShell() || ! mbKeepMainViewShellOnTop))
+ {
+ // The shell is at the top position and is either a) the main
+ // view shell or b) another shell but the main view shell is not
+ // kept at the top position. We do not have to move the shell.
+ bMove = false;
+ }
+ else if (iShell == ++maActiveViewShells.begin()
+ && ! iShell->IsMainViewShell()
+ && mbKeepMainViewShellOnTop)
+ {
+ // The shell is a the second-to-top position, not the main view
+ // shell and the main view shell is kept at the top position.
+ // Therefore we do not have to move the shell.
+ bMove = false;
+ }
+ }
+ else
+ {
+ // The shell is not on the stack. Therefore it can not be moved.
+ // We could insert it but we don't. Use ActivateViewShell() for
+ // that.
+ bMove = false;
+ }
+
+ // When the shell is not at the right position it is removed from the
+ // internal list of shells and inserted at the correct position.
+ if (bMove)
+ {
+ UpdateLock aLock (*this);
+
+ ShellDescriptor aDescriptor(*iShell);
+
+ TakeShellsFromStack(&rShell);
+ maActiveViewShells.erase(iShell);
+
+ // Find out whether to insert at the top or one below.
+ ActiveShellList::iterator aInsertPosition (maActiveViewShells.begin());
+ if (mbKeepMainViewShellOnTop && ! aDescriptor.IsMainViewShell())
+ {
+ if (maActiveViewShells.back().IsMainViewShell())
+ aInsertPosition++;
+ }
+
+ maActiveViewShells.insert(aInsertPosition, aDescriptor);
+ }
+}
+
+
+
+
+SfxShell* ViewShellManager::Implementation::GetShell (ShellId nId) const
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ SfxShell* pShell = NULL;
+
+ // First search the active view shells.
+ ActiveShellList::const_iterator iShell (
+ ::std::find_if (
+ maActiveViewShells.begin(),
+ maActiveViewShells.end(),
+ IsId(nId)));
+ if (iShell != maActiveViewShells.end())
+ pShell = iShell->mpShell;
+ else
+ {
+ // Now search the active sub shells of every active view shell.
+ SubShellList::const_iterator iList;
+ for (iList=maActiveSubShells.begin(); iList!=maActiveSubShells.end(); ++iList)
+ {
+ const SubShellSubList& rList (iList->second);
+ SubShellSubList::const_iterator iSubShell(
+ ::std::find_if(rList.begin(),rList.end(), IsId(nId)));
+ if (iSubShell != rList.end())
+ {
+ pShell = iSubShell->mpShell;
+ break;
+ }
+ }
+ }
+
+ return pShell;
+}
+
+
+
+
+SfxShell* ViewShellManager::Implementation::GetTopShell (void) const
+{
+ OSL_ASSERT(mpTopShell == mrBase.GetSubShell(0));
+ return mpTopShell;
+}
+
+
+
+
+void ViewShellManager::Implementation::LockUpdate (void)
+{
+ mnUpdateLockCount++;
+}
+
+
+
+
+void ViewShellManager::Implementation::UnlockUpdate (void)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ mnUpdateLockCount--;
+ if (mnUpdateLockCount < 0)
+ {
+ // This should not happen.
+ OSL_ASSERT (mnUpdateLockCount>=0);
+ mnUpdateLockCount = 0;
+ }
+ if (mnUpdateLockCount == 0)
+ UpdateShellStack();
+}
+
+
+
+
+/** Update the SFX shell stack (the portion that is visible to us) so that
+ it matches the internal shell stack. This is done in six steps:
+ 1. Create the missing view shells and sub shells.
+ 2. Set up the internal shell stack.
+ 3. Get the SFX shell stack.
+ 4. Find the lowest shell in which the two stacks differ.
+ 5. Remove all shells above and including that shell from the SFX stack.
+ 6. Push all shells of the internal stack on the SFX shell stack that are
+ not already present on the later.
+*/
+void ViewShellManager::Implementation::UpdateShellStack (void)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ // Remember the undo manager from the top-most shell on the stack.
+ SfxShell* pTopMostShell = mrBase.GetSubShell(0);
+ ::svl::IUndoManager* pUndoManager = (pTopMostShell!=NULL)
+ ? pTopMostShell->GetUndoManager()
+ : NULL;
+
+ // 1. Create the missing shells.
+ CreateShells();
+
+
+ // 2. Create the internal target stack.
+ ShellStack aTargetStack;
+ CreateTargetStack(aTargetStack);
+
+
+ // 3. Get SFX shell stack.
+ ShellStack aSfxShellStack;
+ sal_uInt16 nIndex (0);
+ while (mrBase.GetSubShell(nIndex)!=NULL)
+ ++nIndex;
+ aSfxShellStack.reserve(nIndex);
+ while (nIndex-- > 0)
+ aSfxShellStack.push_back(mrBase.GetSubShell(nIndex));
+
+
+#ifdef VERBOSE
+ OSL_TRACE("Current SFX Stack\r");
+ DumpShellStack(aSfxShellStack);
+ OSL_TRACE("Target Stack\r");
+ DumpShellStack(aTargetStack);
+#endif
+
+
+ // 4. Find the lowest shell in which the two stacks differ.
+ ShellStack::const_iterator iSfxShell (aSfxShellStack.begin());
+ ShellStack::iterator iTargetShell (aTargetStack.begin());
+ while (iSfxShell != aSfxShellStack.end()
+ && iTargetShell!=aTargetStack.end()
+ && (*iSfxShell)==(*iTargetShell))
+ {
+ ++iSfxShell;
+ ++iTargetShell;
+ }
+
+
+ // 5. Remove all shells above and including the differing shell from the
+ // SFX stack starting with the shell on top of the stack.
+ while (iSfxShell != aSfxShellStack.end())
+ {
+ SfxShell* pShell = aSfxShellStack.back();
+ aSfxShellStack.pop_back();
+#ifdef VERBOSE
+ OSL_TRACE("removing shell %p from stack\r", pShell);
+#endif
+ mrBase.RemoveSubShell(pShell);
+ }
+
+
+ // 6. Push shells from the given stack onto the SFX stack.
+ mbShellStackIsUpToDate = false;
+ while (iTargetShell != aTargetStack.end())
+ {
+#ifdef VERBOSE
+ OSL_TRACE("pushing shell %p on stack\r", *iTargetShell);
+#endif
+ mrBase.AddSubShell(**iTargetShell);
+ ++iTargetShell;
+
+ // The pushing of the shell on to the shell stack may have lead to
+ // another invocation of this method. In this case we have to abort
+ // pushing shells on the stack and return immediately.
+ if (mbShellStackIsUpToDate)
+ break;
+ }
+ if (mrBase.GetDispatcher() != NULL)
+ mrBase.GetDispatcher()->Flush();
+
+ // Update the pointer to the top-most shell and set its undo manager
+ // to the one of the previous top-most shell.
+ mpTopShell = mrBase.GetSubShell(0);
+ if (mpTopShell!=NULL && pUndoManager!=NULL && mpTopShell->GetUndoManager()==NULL)
+ mpTopShell->SetUndoManager(pUndoManager);
+
+ // Finally tell an invocation of this method on a higher level that it can (has
+ // to) abort and return immediately.
+ mbShellStackIsUpToDate = true;
+
+#ifdef VERBOSE
+ OSL_TRACE("New current stack\r");
+ DumpSfxShellStack();
+#endif
+}
+
+
+
+
+void ViewShellManager::Implementation::TakeShellsFromStack (const SfxShell* pShell)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ // Remember the undo manager from the top-most shell on the stack.
+ SfxShell* pTopMostShell = mrBase.GetSubShell(0);
+ ::svl::IUndoManager* pUndoManager = (pTopMostShell!=NULL)
+ ? pTopMostShell->GetUndoManager()
+ : NULL;
+
+#ifdef VERBOSE
+ OSL_TRACE("TakeShellsFromStack(%p)\r", pShell);
+ DumpSfxShellStack();
+#endif
+
+ // 0.Make sure that the given shell is on the stack. This is a
+ // preparation for the following assertion.
+ for (sal_uInt16 nIndex=0; true; nIndex++)
+ {
+ SfxShell* pShellOnStack = mrBase.GetSubShell(nIndex);
+ if (pShellOnStack == NULL)
+ {
+ // Set pShell to NULL to indicate the following code that the
+ // shell is not on the stack.
+ pShell = NULL;
+ break;
+ }
+ else if (pShellOnStack == pShell)
+ break;
+ }
+
+ if (pShell != NULL)
+ {
+ // 1. Deactivate our shells on the stack before they are removed so
+ // that during the Deactivation() calls the stack is still intact.
+ for (sal_uInt16 nIndex=0; true; nIndex++)
+ {
+ SfxShell* pShellOnStack = mrBase.GetSubShell(nIndex);
+ Deactivate(pShellOnStack);
+ if (pShellOnStack == pShell)
+ break;
+ }
+
+ // 2. Remove the shells from the stack.
+ while (true)
+ {
+ SfxShell* pShellOnStack = mrBase.GetSubShell(0);
+#ifdef VERBOSE
+ OSL_TRACE("removing shell %p from stack\r", pShellOnStack);
+#endif
+ mrBase.RemoveSubShell(pShellOnStack);
+ if (pShellOnStack == pShell)
+ break;
+ }
+
+ // 3. Update the stack.
+ if (mrBase.GetDispatcher() != NULL)
+ mrBase.GetDispatcher()->Flush();
+
+ // Update the pointer to the top-most shell and set its undo manager
+ // to the one of the previous top-most shell.
+ mpTopShell = mrBase.GetSubShell(0);
+ if (mpTopShell!=NULL && pUndoManager!=NULL && mpTopShell->GetUndoManager()==NULL)
+ mpTopShell->SetUndoManager(pUndoManager);
+ }
+
+#ifdef VERBOSE
+ OSL_TRACE("Sfx shell stack is:\r");
+ DumpSfxShellStack();
+#endif
+}
+
+
+
+
+void ViewShellManager::Implementation::CreateShells (void)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ // Iterate over all view shells.
+ ShellStack aShellStack;
+ ActiveShellList::reverse_iterator iShell;
+ for (iShell=maActiveViewShells.rbegin(); iShell!=maActiveViewShells.rend(); ++iShell)
+ {
+ // Get the list of associated sub shells.
+ SubShellList::iterator iList (maActiveSubShells.find(iShell->mpShell));
+ if (iList != maActiveSubShells.end())
+ {
+ SubShellSubList& rList (iList->second);
+
+ // Iterate over all sub shells of the current view shell.
+ SubShellSubList::iterator iSubShell;
+ for (iSubShell=rList.begin(); iSubShell!=rList.end(); ++iSubShell)
+ {
+ if (iSubShell->mpShell == NULL)
+ {
+ *iSubShell = CreateSubShell(iShell->mpShell,iSubShell->mnId,NULL,NULL);
+ }
+ }
+ }
+ }
+}
+
+
+
+
+void ViewShellManager::Implementation::CreateTargetStack (ShellStack& rStack) const
+{
+ // Create a local stack of the shells that are to push on the shell
+ // stack. We can thus safly create the required shells wile still
+ // having a valid shell stack.
+ for (ActiveShellList::const_reverse_iterator iViewShell (maActiveViewShells.rbegin());
+ iViewShell != maActiveViewShells.rend();
+ ++iViewShell)
+ {
+ // Possibly place the form shell below the current view shell.
+ if ( ! mbFormShellAboveParent
+ && mpFormShell!=NULL
+ && iViewShell->mpShell==mpFormShellParent)
+ {
+ rStack.push_back(mpFormShell);
+ }
+
+ // Put the view shell itself on the local stack.
+ rStack.push_back (iViewShell->mpShell);
+
+ // Possibly place the form shell above the current view shell.
+ if (mbFormShellAboveParent
+ && mpFormShell!=NULL
+ && iViewShell->mpShell==mpFormShellParent)
+ {
+ rStack.push_back(mpFormShell);
+ }
+
+ // Add all other sub shells.
+ SubShellList::const_iterator iList (maActiveSubShells.find(iViewShell->mpShell));
+ if (iList != maActiveSubShells.end())
+ {
+ const SubShellSubList& rList (iList->second);
+ SubShellSubList::const_reverse_iterator iSubShell;
+ for (iSubShell=rList.rbegin(); iSubShell!=rList.rend(); ++iSubShell)
+ if (iSubShell->mpShell != mpFormShell)
+ rStack.push_back(iSubShell->mpShell);
+ }
+ }
+}
+
+
+
+
+IMPL_LINK(ViewShellManager::Implementation, WindowEventHandler, VclWindowEvent*, pEvent)
+{
+ if (pEvent != NULL)
+ {
+ ::Window* pEventWindow
+ = static_cast<VclWindowEvent*>(pEvent)->GetWindow();
+
+ switch (pEvent->GetId())
+ {
+ case VCLEVENT_WINDOW_GETFOCUS:
+ {
+ for (ActiveShellList::iterator aI(maActiveViewShells.begin());
+ aI!=maActiveViewShells.end();
+ aI++)
+ {
+ if (pEventWindow == static_cast< ::Window*>(aI->GetWindow()))
+ {
+ MoveToTop(*aI->mpShell);
+ break;
+ }
+ }
+ }
+ break;
+
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ break;
+ }
+ }
+ return sal_True;
+}
+
+
+
+
+ShellDescriptor ViewShellManager::Implementation::CreateSubShell (
+ SfxShell* pParentShell,
+ ShellId nShellId,
+ ::Window* pParentWindow,
+ FrameView* pFrameView)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+ ShellDescriptor aResult;
+
+ // Look up the factories for the parent shell.
+ ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange(
+ maShellFactories.equal_range(pParentShell));
+
+ // Try all factories to create the shell.
+ for (FactoryList::const_iterator iFactory=aRange.first; iFactory!=aRange.second; ++iFactory)
+ {
+ SharedShellFactory pFactory = iFactory->second;
+ if (pFactory != NULL)
+ aResult.mpShell = pFactory->CreateShell(nShellId, pParentWindow, pFrameView);
+
+ // Exit the loop when the shell has been successfully created.
+ if (aResult.mpShell != NULL)
+ {
+ aResult.mpFactory = pFactory;
+ aResult.mnId = nShellId;
+ break;
+ }
+ }
+
+ return aResult;
+}
+
+
+
+
+void ViewShellManager::Implementation::DestroyViewShell (
+ const ShellDescriptor& rDescriptor)
+{
+ OSL_ASSERT(rDescriptor.mpShell != NULL);
+
+ ::Window* pWindow = rDescriptor.GetWindow();
+ if (pWindow != NULL)
+ {
+ pWindow->RemoveEventListener(
+ LINK(this, ViewShellManager::Implementation, WindowEventHandler));
+ }
+
+ // Destroy the sub shell factories.
+ ::std::pair<FactoryList::iterator,FactoryList::iterator> aRange(
+ maShellFactories.equal_range(rDescriptor.mpShell));
+ if (aRange.first != maShellFactories.end())
+ maShellFactories.erase(aRange.first, aRange.second);
+
+ // Release the shell.
+ if (rDescriptor.mpFactory.get() != NULL)
+ rDescriptor.mpFactory->ReleaseShell(rDescriptor.mpShell);
+}
+
+
+
+
+void ViewShellManager::Implementation::DestroySubShell (
+ const SfxShell& rParentShell,
+ const ShellDescriptor& rDescriptor)
+{
+ (void)rParentShell;
+ OSL_ASSERT(rDescriptor.mpFactory.get() != NULL);
+ rDescriptor.mpFactory->ReleaseShell(rDescriptor.mpShell);
+}
+
+
+
+
+void ViewShellManager::Implementation::InvalidateAllSubShells (const SfxShell* pParentShell)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ SubShellList::iterator iList (maActiveSubShells.find(pParentShell));
+ if (iList != maActiveSubShells.end())
+ {
+ SubShellSubList& rList (iList->second);
+ SubShellSubList::iterator iShell;
+ for (iShell=rList.begin(); iShell!=rList.end(); ++iShell)
+ if (iShell->mpShell != NULL)
+ iShell->mpShell->Invalidate();
+ }
+}
+
+
+
+
+void ViewShellManager::Implementation::Shutdown (void)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ // Take stacked shells from stack.
+ if ( ! maActiveViewShells.empty())
+ {
+ UpdateLock aLock (*this);
+
+
+ while ( ! maActiveViewShells.empty())
+ {
+ SfxShell* pShell = maActiveViewShells.front().mpShell;
+ if (pShell != NULL)
+ {
+ ViewShell* pViewShell = dynamic_cast<ViewShell*>(pShell);
+ if (pViewShell != NULL)
+ DeactivateViewShell(*pViewShell);
+ else
+ DeactivateShell(*pShell);
+ }
+ else
+ {
+ DBG_ASSERT(false,
+ "ViewShellManager::Implementation::Shutdown(): empty active shell descriptor");
+ maActiveViewShells.pop_front();
+ }
+ }
+ }
+ mrBase.RemoveSubShell (NULL);
+
+ maShellFactories.clear();
+}
+
+
+
+
+#ifdef VERBOSE
+void ViewShellManager::Implementation::DumpShellStack (const ShellStack& rStack)
+{
+ ShellStack::const_reverse_iterator iEntry;
+ for (iEntry=rStack.rbegin(); iEntry!=rStack.rend(); ++iEntry)
+ if (*iEntry != NULL)
+ OSL_TRACE (" %p : %s\r",
+ *iEntry,
+ ::rtl::OUStringToOString((*iEntry)->GetName(),RTL_TEXTENCODING_UTF8).getStr());
+ else
+ OSL_TRACE(" null\r");
+}
+
+
+
+
+void ViewShellManager::Implementation::DumpSfxShellStack (void)
+{
+ ShellStack aSfxShellStack;
+ sal_uInt16 nIndex (0);
+ while (mrBase.GetSubShell(nIndex)!=NULL)
+ ++nIndex;
+ aSfxShellStack.reserve(nIndex);
+ while (nIndex-- > 0)
+ aSfxShellStack.push_back(mrBase.GetSubShell(nIndex));
+ DumpShellStack(aSfxShellStack);
+}
+#endif
+
+
+
+void ViewShellManager::Implementation::Deactivate (SfxShell* pShell)
+{
+ OSL_ASSERT(pShell!=NULL);
+
+ // We have to end a text edit for view shells that are to be taken from
+ // the shell stack.
+ ViewShell* pViewShell = dynamic_cast<ViewShell*>(pShell);
+ if (pViewShell != NULL)
+ {
+ sd::View* pView = pViewShell->GetView();
+ if (pView!=NULL && pView->IsTextEdit())
+ {
+ pView->SdrEndTextEdit();
+ pView->UnmarkAll();
+ pViewShell->GetViewFrame()->GetDispatcher()->Execute(
+ SID_OBJECT_SELECT,
+ SFX_CALLMODE_ASYNCHRON);
+ }
+ }
+
+ // Now we can deactivate the shell.
+ pShell->Deactivate(sal_True);
+}
+
+
+
+
+void ViewShellManager::Implementation::SetFormShell (
+ const ViewShell* pFormShellParent,
+ FmFormShell* pFormShell,
+ bool bFormShellAboveParent)
+{
+ ::osl::MutexGuard aGuard (maMutex);
+
+ mpFormShellParent = pFormShellParent;
+ mpFormShell = pFormShell;
+ mbFormShellAboveParent = bFormShellAboveParent;
+}
+
+
+
+
+namespace {
+
+ShellDescriptor::ShellDescriptor (void)
+ : mpShell(NULL),
+ mnId(0),
+ mpFactory()
+{
+}
+
+
+
+
+ShellDescriptor::ShellDescriptor (
+ SfxShell* pShell,
+ ShellId nId)
+ : mpShell(pShell),
+ mnId(nId),
+ mpFactory()
+{
+}
+
+
+
+
+ShellDescriptor::ShellDescriptor (const ShellDescriptor& rDescriptor)
+ : mpShell(rDescriptor.mpShell),
+ mnId(rDescriptor.mnId),
+ mpFactory(rDescriptor.mpFactory)
+{
+}
+
+
+
+
+ShellDescriptor& ShellDescriptor::operator= (const ShellDescriptor& rDescriptor)
+{
+ mpShell = rDescriptor.mpShell;
+ mnId = rDescriptor.mnId;
+ mpFactory = rDescriptor.mpFactory;
+ return *this;
+}
+
+
+
+
+bool ShellDescriptor::IsMainViewShell (void) const
+{
+ ViewShell* pViewShell = dynamic_cast<ViewShell*>(mpShell);
+ if (pViewShell != NULL)
+ return pViewShell->IsMainViewShell();
+ else
+ return false;
+}
+
+
+
+
+::Window* ShellDescriptor::GetWindow (void) const
+{
+ ViewShell* pViewShell = dynamic_cast<ViewShell*>(mpShell);
+ if (pViewShell != NULL)
+ return pViewShell->GetActiveWindow();
+ else
+ return NULL;
+}
+
+
+
+} // end of anonymous namespace
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/ViewTabBar.cxx b/sd/source/ui/view/ViewTabBar.cxx
new file mode 100755
index 000000000000..0c0cd2b9836e
--- /dev/null
+++ b/sd/source/ui/view/ViewTabBar.cxx
@@ -0,0 +1,716 @@
+/*************************************************************************
+ *
+ * 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 "ViewTabBar.hxx"
+
+#define USE_TAB_CONTROL
+
+#include "ViewShell.hxx"
+#include "ViewShellBase.hxx"
+#include "DrawViewShell.hxx"
+#include "FrameView.hxx"
+#include "EventMultiplexer.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include "framework/Pane.hxx"
+#include "DrawController.hxx"
+
+#include "sdresid.hxx"
+#include "strings.hrc"
+#include "helpids.h"
+#include "Client.hxx"
+#include <vcl/svapp.hxx>
+#include <vcl/tabpage.hxx>
+#include <vos/mutex.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <com/sun/star/drawing/framework/ResourceId.hpp>
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/processfactory.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+using ::sd::framework::FrameworkHelper;
+using ::sd::tools::EventMultiplexerEvent;
+using ::rtl::OUString;
+
+namespace sd {
+
+namespace {
+bool IsEqual (const TabBarButton& rButton1, const TabBarButton& rButton2)
+{
+ return (
+ (rButton1.ResourceId.is()
+ && rButton2.ResourceId.is()
+ && rButton1.ResourceId->compareTo(rButton2.ResourceId)==0)
+ || rButton1.ButtonLabel == rButton2.ButtonLabel);
+}
+
+class TabBarControl : public ::TabControl
+{
+public:
+ TabBarControl (
+ ::Window* pParentWindow,
+ const ::rtl::Reference<ViewTabBar>& rpViewTabBar);
+ virtual void Paint (const Rectangle& rRect);
+ virtual void ActivatePage (void);
+private:
+ ::rtl::Reference<ViewTabBar> mpViewTabBar;
+};
+
+} // end of anonymous namespace
+
+
+
+
+
+class ViewTabPage : public TabPage
+{
+public:
+ ViewTabPage (Window* pParent) : TabPage(pParent) {}
+ virtual void Resize (void)
+ { SetPosSizePixel(Point(0,0),GetParent()->GetOutputSizePixel()); }
+};
+
+
+
+
+//===== ViewTabBar ============================================================
+
+ViewTabBar::ViewTabBar (
+ const Reference<XResourceId>& rxViewTabBarId,
+ const Reference<frame::XController>& rxController)
+ : ViewTabBarInterfaceBase(maMutex),
+ mpTabControl(new TabBarControl(GetAnchorWindow(rxViewTabBarId,rxController), this)),
+ mxController(rxController),
+ maTabBarButtons(),
+ mpTabPage(NULL),
+ mxViewTabBarId(rxViewTabBarId),
+ mpViewShellBase(NULL)
+{
+ // Set one new tab page for all tab entries. We need it only to
+ // determine the height of the tab bar.
+ mpTabPage.reset(new TabPage (mpTabControl.get()));
+ mpTabPage->Hide();
+
+ // add some space before the tabitems
+ mpTabControl->SetItemsOffset(Point(5, 3));
+
+ // Tunnel through the controller and use the ViewShellBase to obtain the
+ // view frame.
+ try
+ {
+ Reference<lang::XUnoTunnel> xTunnel (mxController, UNO_QUERY_THROW);
+ DrawController* pController = reinterpret_cast<DrawController*>(
+ xTunnel->getSomething(DrawController::getUnoTunnelId()));
+ mpViewShellBase = pController->GetViewShellBase();
+ }
+ catch(RuntimeException&)
+ {}
+
+ // Register as listener at XConfigurationController.
+ Reference<XControllerManager> xControllerManager (mxController, UNO_QUERY);
+ if (xControllerManager.is())
+ {
+ mxConfigurationController = xControllerManager->getConfigurationController();
+ if (mxConfigurationController.is())
+ {
+ mxConfigurationController->addConfigurationChangeListener(
+ this,
+ FrameworkHelper::msResourceActivationEvent,
+ Any());
+ }
+ }
+
+ mpTabControl->Show();
+
+ if (mpViewShellBase != NULL
+ && rxViewTabBarId->isBoundToURL(
+ FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
+ {
+ mpViewShellBase->SetViewTabBar(this);
+ }
+}
+
+
+
+
+ViewTabBar::~ViewTabBar (void)
+{
+}
+
+
+
+
+void ViewTabBar::disposing (void)
+{
+ if (mpViewShellBase != NULL
+ && mxViewTabBarId->isBoundToURL(
+ FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
+ {
+ mpViewShellBase->SetViewTabBar(NULL);
+ }
+
+ if (mxConfigurationController.is())
+ {
+ // Unregister listener from XConfigurationController.
+ try
+ {
+ mxConfigurationController->removeConfigurationChangeListener(this);
+ }
+ catch (lang::DisposedException e)
+ {
+ // Receiving a disposed exception is the normal case. Is there
+ // a way to avoid it?
+ }
+ mxConfigurationController = NULL;
+ }
+
+ {
+ const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
+ // Set all references to the one tab page to NULL and delete the page.
+ for (sal_uInt16 nIndex=0; nIndex<mpTabControl->GetPageCount(); ++nIndex)
+ mpTabControl->SetTabPage(nIndex, NULL);
+ mpTabPage.reset();
+ mpTabControl.reset();
+ }
+
+ mxController = NULL;
+}
+
+
+
+
+::boost::shared_ptr< ::TabControl> ViewTabBar::GetTabControl (void) const
+{
+ return mpTabControl;
+}
+
+
+
+
+::Window* ViewTabBar::GetAnchorWindow(
+ const Reference<XResourceId>& rxViewTabBarId,
+ const Reference<frame::XController>& rxController)
+{
+ ::Window* pWindow = NULL;
+ ViewShellBase* pBase = NULL;
+
+ // Tunnel through the controller and use the ViewShellBase to obtain the
+ // view frame.
+ try
+ {
+ Reference<lang::XUnoTunnel> xTunnel (rxController, UNO_QUERY_THROW);
+ DrawController* pController = reinterpret_cast<DrawController*>(
+ xTunnel->getSomething(DrawController::getUnoTunnelId()));
+ pBase = pController->GetViewShellBase();
+ }
+ catch(RuntimeException&)
+ {}
+
+ // The ViewTabBar supports at the moment only the center pane.
+ if (rxViewTabBarId.is()
+ && rxViewTabBarId->isBoundToURL(
+ FrameworkHelper::msCenterPaneURL, AnchorBindingMode_DIRECT))
+ {
+ if (pBase != NULL && pBase->GetViewFrame() != NULL)
+ pWindow = &pBase->GetViewFrame()->GetWindow();
+ }
+
+ // The rest is (at the moment) just for the emergency case.
+ if (pWindow == NULL)
+ {
+ Reference<XPane> xPane;
+ try
+ {
+ Reference<XControllerManager> xControllerManager (rxController, UNO_QUERY_THROW);
+ Reference<XConfigurationController> xCC (
+ xControllerManager->getConfigurationController());
+ if (xCC.is())
+ xPane = Reference<XPane>(xCC->getResource(rxViewTabBarId->getAnchor()), UNO_QUERY);
+ }
+ catch (RuntimeException&)
+ {}
+
+ // Tunnel through the XWindow to the VCL side.
+ try
+ {
+ Reference<lang::XUnoTunnel> xTunnel (xPane, UNO_QUERY_THROW);
+ framework::Pane* pPane = reinterpret_cast<framework::Pane*>(
+ xTunnel->getSomething(framework::Pane::getUnoTunnelId()));
+ if (pPane != NULL)
+ pWindow = pPane->GetWindow()->GetParent();
+ }
+ catch (RuntimeException&)
+ {}
+ }
+
+ return pWindow;
+}
+
+
+
+
+//----- XConfigurationChangeListener ------------------------------------------
+
+void SAL_CALL ViewTabBar::notifyConfigurationChange (
+ const ConfigurationChangeEvent& rEvent)
+ throw (RuntimeException)
+{
+ if (rEvent.Type.equals(FrameworkHelper::msResourceActivationEvent)
+ && rEvent.ResourceId->getResourceURL().match(FrameworkHelper::msViewURLPrefix)
+ && rEvent.ResourceId->isBoundTo(mxViewTabBarId->getAnchor(), AnchorBindingMode_DIRECT))
+ {
+ UpdateActiveButton();
+ }
+}
+
+
+
+
+//----- XEventListener --------------------------------------------------------
+
+void SAL_CALL ViewTabBar::disposing(
+ const lang::EventObject& rEvent)
+ throw (RuntimeException)
+{
+ if (rEvent.Source == mxConfigurationController)
+ {
+ mxConfigurationController = NULL;
+ mxController = NULL;
+ }
+}
+
+
+
+
+//----- XTabBar ---------------------------------------------------------------
+
+void SAL_CALL ViewTabBar::addTabBarButtonAfter (
+ const TabBarButton& rButton,
+ const TabBarButton& rAnchor)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
+ AddTabBarButton(rButton, rAnchor);
+}
+
+
+
+
+void SAL_CALL ViewTabBar::appendTabBarButton (const TabBarButton& rButton)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
+ AddTabBarButton(rButton);
+}
+
+
+
+void SAL_CALL ViewTabBar::removeTabBarButton (const TabBarButton& rButton)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
+ RemoveTabBarButton(rButton);
+}
+
+
+
+
+sal_Bool SAL_CALL ViewTabBar::hasTabBarButton (const TabBarButton& rButton)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
+ return HasTabBarButton(rButton);
+}
+
+
+
+
+Sequence<TabBarButton> SAL_CALL ViewTabBar::getTabBarButtons (void)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
+ return GetTabBarButtons();
+}
+
+
+
+
+//----- XResource -------------------------------------------------------------
+
+Reference<XResourceId> SAL_CALL ViewTabBar::getResourceId (void)
+ throw (RuntimeException)
+{
+ return mxViewTabBarId;
+}
+
+
+
+
+sal_Bool SAL_CALL ViewTabBar::isAnchorOnly (void)
+ throw (RuntimeException)
+{
+ return false;
+}
+
+
+
+
+//----- XUnoTunnel ------------------------------------------------------------
+
+const Sequence<sal_Int8>& ViewTabBar::getUnoTunnelId (void)
+{
+ static Sequence<sal_Int8>* pSequence = NULL;
+ if (pSequence == NULL)
+ {
+ const ::vos::OGuard aSolarGuard (Application::GetSolarMutex());
+ if (pSequence == NULL)
+ {
+ static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
+ rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
+ pSequence = &aSequence;
+ }
+ }
+ return *pSequence;
+}
+
+
+
+
+sal_Int64 SAL_CALL ViewTabBar::getSomething (const Sequence<sal_Int8>& rId)
+ throw (RuntimeException)
+{
+ sal_Int64 nResult = 0;
+
+ if (rId.getLength() == 16
+ && rtl_compareMemory(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16) == 0)
+ {
+ nResult = reinterpret_cast<sal_Int64>(this);
+ }
+
+ return nResult;
+}
+
+
+
+
+//-----------------------------------------------------------------------------
+
+bool ViewTabBar::ActivatePage (void)
+{
+ try
+ {
+ Reference<XControllerManager> xControllerManager (mxController,UNO_QUERY_THROW);
+ Reference<XConfigurationController> xConfigurationController (
+ xControllerManager->getConfigurationController());
+ if ( ! xConfigurationController.is())
+ throw RuntimeException();
+ Reference<XView> xView;
+ try
+ {
+ xView = Reference<XView>(xConfigurationController->getResource(
+ ResourceId::create(
+ ::comphelper::getProcessComponentContext(),
+ FrameworkHelper::msCenterPaneURL)),
+ UNO_QUERY);
+ }
+ catch (DeploymentException)
+ {
+ }
+
+ Client* pIPClient = NULL;
+ if (mpViewShellBase != NULL)
+ pIPClient = dynamic_cast<Client*>(mpViewShellBase->GetIPClient());
+ if (pIPClient==NULL || ! pIPClient->IsObjectInPlaceActive())
+ {
+ sal_uInt16 nIndex (mpTabControl->GetCurPageId() - 1);
+ if (nIndex < maTabBarButtons.size())
+ {
+ xConfigurationController->requestResourceActivation(
+ maTabBarButtons[nIndex].ResourceId,
+ ResourceActivationMode_REPLACE);
+ }
+
+ return true;
+ }
+ else
+ {
+ // When we run into this else branch then we have an active OLE
+ // object. We ignore the request to switch views. Additionally
+ // we put the active tab back to the one for the current view.
+ UpdateActiveButton();
+ }
+ }
+ catch (RuntimeException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return false;
+}
+
+
+
+
+int ViewTabBar::GetHeight (void)
+{
+ int nHeight (0);
+
+ if (maTabBarButtons.size() > 0)
+ {
+ TabPage* pActivePage (mpTabControl->GetTabPage(
+ mpTabControl->GetCurPageId()));
+ if (pActivePage!=NULL && mpTabControl->IsReallyVisible())
+ nHeight = pActivePage->GetPosPixel().Y();
+
+ if (nHeight <= 0)
+ // Using a default when the real height can not be determined.
+ // To get correct height this method should be called when the
+ // control is visible.
+ nHeight = 21;
+ }
+
+ return nHeight;
+}
+
+
+
+
+void ViewTabBar::AddTabBarButton (
+ const ::com::sun::star::drawing::framework::TabBarButton& rButton,
+ const ::com::sun::star::drawing::framework::TabBarButton& rAnchor)
+{
+ sal_uInt32 nIndex;
+
+ if ( ! rAnchor.ResourceId.is()
+ || (rAnchor.ResourceId->getResourceURL().getLength() == 0
+ && rAnchor.ButtonLabel.getLength() == 0))
+ {
+ nIndex = 0;
+ }
+ else
+ {
+ for (nIndex=0; nIndex<maTabBarButtons.size(); ++nIndex)
+ {
+ if (IsEqual(maTabBarButtons[nIndex], rAnchor))
+ {
+ ++nIndex;
+ break;
+ }
+ }
+ }
+
+ AddTabBarButton(rButton,nIndex);
+}
+
+
+
+
+void ViewTabBar::AddTabBarButton (
+ const ::com::sun::star::drawing::framework::TabBarButton& rButton)
+{
+ AddTabBarButton(rButton, maTabBarButtons.size());
+}
+
+
+
+
+void ViewTabBar::AddTabBarButton (
+ const ::com::sun::star::drawing::framework::TabBarButton& rButton,
+ sal_Int32 nPosition)
+{
+ if (nPosition>=0
+ && nPosition<=mpTabControl->GetPageCount())
+ {
+ sal_uInt16 nIndex ((sal_uInt16)nPosition);
+
+ // Insert the button into our local array.
+ maTabBarButtons.insert(maTabBarButtons.begin()+nIndex, rButton);
+ UpdateTabBarButtons();
+ UpdateActiveButton();
+ }
+}
+
+
+
+
+void ViewTabBar::RemoveTabBarButton (
+ const ::com::sun::star::drawing::framework::TabBarButton& rButton)
+{
+ sal_uInt16 nIndex;
+ for (nIndex=0; nIndex<maTabBarButtons.size(); ++nIndex)
+ {
+ if (IsEqual(maTabBarButtons[nIndex], rButton))
+ {
+ maTabBarButtons.erase(maTabBarButtons.begin()+nIndex);
+ UpdateTabBarButtons();
+ UpdateActiveButton();
+ break;
+ }
+ }
+}
+
+
+
+
+bool ViewTabBar::HasTabBarButton (
+ const ::com::sun::star::drawing::framework::TabBarButton& rButton)
+{
+ bool bResult (false);
+
+ for (sal_uInt32 nIndex=0; nIndex<maTabBarButtons.size(); ++nIndex)
+ {
+ if (IsEqual(maTabBarButtons[nIndex], rButton))
+ {
+ bResult = true;
+ break;
+ }
+ }
+
+ return bResult;
+}
+
+
+
+
+::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
+ ViewTabBar::GetTabBarButtons (void)
+{
+ sal_uInt32 nCount (maTabBarButtons.size());
+ ::com::sun::star::uno::Sequence<com::sun::star::drawing::framework::TabBarButton>
+ aList (nCount);
+
+ for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
+ aList[nIndex] = maTabBarButtons[nIndex];
+
+ return aList;
+}
+
+
+
+
+void ViewTabBar::UpdateActiveButton (void)
+{
+ Reference<XView> xView;
+ if (mpViewShellBase != NULL)
+ xView = FrameworkHelper::Instance(*mpViewShellBase)->GetView(
+ mxViewTabBarId->getAnchor());
+ if (xView.is())
+ {
+ Reference<XResourceId> xViewId (xView->getResourceId());
+ for (sal_uInt16 nIndex=0; nIndex<maTabBarButtons.size(); ++nIndex)
+ {
+ if (maTabBarButtons[nIndex].ResourceId->compareTo(xViewId) == 0)
+ {
+ mpTabControl->SetCurPageId(nIndex+1);
+ mpTabControl->::TabControl::ActivatePage();
+ break;
+ }
+ }
+ }
+}
+
+
+
+
+void ViewTabBar::UpdateTabBarButtons (void)
+{
+ TabBarButtonList::const_iterator iTab;
+ sal_uInt16 nPageCount (mpTabControl->GetPageCount());
+ sal_uInt16 nIndex;
+ for (iTab=maTabBarButtons.begin(),nIndex=1; iTab!=maTabBarButtons.end(); ++iTab,++nIndex)
+ {
+ // Create a new tab when there are not enough.
+ if (nPageCount < nIndex)
+ mpTabControl->InsertPage(nIndex, iTab->ButtonLabel);
+
+ // Update the tab.
+ mpTabControl->SetPageText(nIndex, iTab->ButtonLabel);
+ mpTabControl->SetHelpText(nIndex, iTab->HelpText);
+ mpTabControl->SetTabPage(nIndex, mpTabPage.get());
+ }
+
+ // Delete tabs that are no longer used.
+ for (; nIndex<=nPageCount; ++nIndex)
+ mpTabControl->RemovePage(nIndex);
+
+ mpTabPage->Hide();
+}
+
+
+
+
+//===== TabBarControl =========================================================
+
+TabBarControl::TabBarControl (
+ ::Window* pParentWindow,
+ const ::rtl::Reference<ViewTabBar>& rpViewTabBar)
+ : ::TabControl(pParentWindow),
+ mpViewTabBar(rpViewTabBar)
+{
+}
+
+
+
+
+void TabBarControl::Paint (const Rectangle& rRect)
+{
+ Color aOriginalFillColor (GetFillColor());
+ Color aOriginalLineColor (GetLineColor());
+
+ // Because the actual window background is transparent--to avoid
+ // flickering due to multiple background paintings by this and by child
+ // windows--we have to paint the background for this control explicitly:
+ // the actual control is not painted over its whole bounding box.
+ SetFillColor (GetSettings().GetStyleSettings().GetDialogColor());
+ SetLineColor ();
+ DrawRect (rRect);
+ ::TabControl::Paint (rRect);
+
+ SetFillColor (aOriginalFillColor);
+ SetLineColor (aOriginalLineColor);
+}
+
+
+
+
+void TabBarControl::ActivatePage (void)
+{
+ if (mpViewTabBar->ActivatePage())
+ {
+ // Call the parent so that the correct tab is highlighted.
+ this->::TabControl::ActivatePage();
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/WindowUpdater.cxx b/sd/source/ui/view/WindowUpdater.cxx
new file mode 100644
index 000000000000..3e074e0108ad
--- /dev/null
+++ b/sd/source/ui/view/WindowUpdater.cxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * 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 "WindowUpdater.hxx"
+#include "ViewShell.hxx"
+#include "Window.hxx"
+#include "drawdoc.hxx"
+#include "View.hxx"
+
+#ifndef _SPLIT_HXX
+#include <vcl/split.hxx>
+#endif
+#include <sfx2/childwin.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svl/smplhint.hxx>
+
+#include <algorithm>
+
+namespace sd {
+
+WindowUpdater::WindowUpdater (void)
+ : mpViewShell (NULL),
+ mpDocument (NULL)
+{
+ maCTLOptions.AddListener(this);
+}
+
+
+
+
+WindowUpdater::~WindowUpdater (void) throw ()
+{
+ maCTLOptions.RemoveListener(this);
+}
+
+
+
+
+void WindowUpdater::RegisterWindow (::Window* pWindow)
+{
+ if (pWindow != NULL)
+ {
+ tWindowList::iterator aWindowIterator (
+ ::std::find (
+ maWindowList.begin(), maWindowList.end(), pWindow));
+ if (aWindowIterator == maWindowList.end())
+ {
+ // Update the device once right now and add it to the list.
+ Update (pWindow);
+ maWindowList.push_back (pWindow);
+ }
+ }
+}
+
+
+
+
+void WindowUpdater::UnregisterWindow (::Window* pWindow)
+{
+ tWindowList::iterator aWindowIterator (
+ ::std::find (
+ maWindowList.begin(), maWindowList.end(), pWindow));
+ if (aWindowIterator != maWindowList.end())
+ {
+ maWindowList.erase (aWindowIterator);
+ }
+}
+
+
+
+void WindowUpdater::SetViewShell (ViewShell& rViewShell)
+{
+ mpViewShell = &rViewShell;
+}
+
+
+
+
+void WindowUpdater::SetDocument (SdDrawDocument* pDocument)
+{
+ mpDocument = pDocument;
+}
+
+
+
+
+void WindowUpdater::Update (
+ OutputDevice* pDevice,
+ SdDrawDocument* pDocument) const
+{
+ if (pDevice != NULL)
+ {
+ UpdateWindow (pDevice);
+ if (pDocument != NULL)
+ pDocument->ReformatAllTextObjects();
+ }
+}
+
+
+
+
+void WindowUpdater::UpdateWindow (OutputDevice* pDevice) const
+{
+ if (pDevice != NULL)
+ {
+ SvtCTLOptions::TextNumerals aNumeralMode (maCTLOptions.GetCTLTextNumerals());
+
+ LanguageType aLanguage;
+ // Now this is a bit confusing. The numerals in arabic languages
+ // are Hindi numerals and what the western world generally uses are
+ // arabic numerals. The digits used in the Hindi language are not
+ // used at all.
+ switch (aNumeralMode)
+ {
+ case SvtCTLOptions::NUMERALS_HINDI:
+ aLanguage = LANGUAGE_ARABIC_SAUDI_ARABIA;
+ break;
+
+ case SvtCTLOptions::NUMERALS_SYSTEM:
+ aLanguage = LANGUAGE_SYSTEM;
+ break;
+
+ case SvtCTLOptions::NUMERALS_ARABIC:
+ default:
+ aLanguage = LANGUAGE_ENGLISH;
+ break;
+ }
+
+ pDevice->SetDigitLanguage (aLanguage);
+ }
+}
+
+
+
+
+void WindowUpdater::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
+{
+ // #110094#-7
+ // Clear the master page cache so that master pages will be redrawn.
+ //if (mpViewShell != NULL)
+ //{
+ // SdView* pView = mpViewShell->GetView();
+ // if (pView != NULL)
+ // pView->ReleaseMasterPagePaintCache ();
+ //}
+ // Set the current state at all registered output devices.
+ tWindowList::iterator aWindowIterator (maWindowList.begin());
+ while (aWindowIterator != maWindowList.end())
+ Update (*aWindowIterator++);
+
+ // Reformat the document for the modified state to take effect.
+ if (mpDocument != NULL)
+ mpDocument->ReformatAllTextObjects();
+
+ // Invalidate the windows to make the modified state visible.
+ aWindowIterator = maWindowList.begin();
+ while (aWindowIterator != maWindowList.end())
+ (*aWindowIterator++)->Invalidate();
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/bmcache.cxx b/sd/source/ui/view/bmcache.cxx
new file mode 100755
index 000000000000..35739b46ff72
--- /dev/null
+++ b/sd/source/ui/view/bmcache.cxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * 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 <limits.h> // LONG_MAX
+#include <tools/solar.h>
+#include <svtools/grfmgr.hxx>
+#include "bmcache.hxx"
+
+// eine Struktur fuer die Cache-Eintraege
+struct BitmapCacheEntry
+{
+ const SdPage* pPage;
+ GraphicObject* pGraphicObject;
+ sal_uInt32 nSizeBytes;
+ long nZoom;
+};
+
+/*************************************************************************
+|*
+|* Destruktor, loescht die gespeicherten Bitmaps
+|*
+\************************************************************************/
+
+BitmapCache::~BitmapCache()
+{
+ for( void* pEntry = aEntries.First(); pEntry; pEntry = aEntries.Next() )
+ {
+ delete static_cast< BitmapCacheEntry* >( pEntry )->pGraphicObject;
+ delete static_cast< BitmapCacheEntry* >( pEntry );
+ }
+}
+
+void BitmapCache::Remove( const SdPage* pPage )
+{
+ for( sal_uLong nPos = 0; nPos < aEntries.Count(); )
+ {
+ BitmapCacheEntry* pCand = (BitmapCacheEntry*) aEntries.GetObject( nPos );
+
+ if( pCand->pPage == pPage )
+ {
+ pCand = (BitmapCacheEntry*) aEntries.Remove((sal_uLong)nPos);
+ delete pCand->pGraphicObject;
+ delete pCand;
+ }
+ else
+ nPos++;
+ }
+}
+
+
diff --git a/sd/source/ui/view/clview.cxx b/sd/source/ui/view/clview.cxx
new file mode 100644
index 000000000000..3d6197d00db5
--- /dev/null
+++ b/sd/source/ui/view/clview.cxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * 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 <sfx2/app.hxx>
+
+
+#include "ClientView.hxx"
+#include "drawview.hxx"
+#include "sdpage.hxx"
+
+class DrawDocShell;
+
+namespace sd {
+
+class DrawViewShell;
+
+
+/*************************************************************************
+|*
+|* Ctor: Die ClientView wird fuer DrawDocShell::Draw() verwendet
+|*
+\************************************************************************/
+
+ClientView::ClientView(
+ DrawDocShell* pDocSh,
+ OutputDevice* pOutDev,
+ DrawViewShell* pShell)
+ : DrawView (pDocSh, pOutDev, pShell)
+{
+}
+
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+
+ClientView::~ClientView()
+{
+}
+
+/*************************************************************************
+|*
+|* Wenn die View kein Invalidate() an den Fenstern durchfuehren soll, muss
+|* man diese Methode ueberladen und entsprechend anders reagieren.
+|*
+\************************************************************************/
+
+void ClientView::InvalidateOneWin(::Window& rWin)
+{
+ Region aRegion;
+ CompleteRedraw(&rWin, aRegion);
+}
+
+/*************************************************************************
+|*
+|* Wenn die View kein Invalidate() an den Fenstern durchfuehren soll, muss
+|* man diese Methode ueberladen und entsprechend anders reagieren.
+|*
+\************************************************************************/
+
+void ClientView::InvalidateOneWin(::Window& rWin, const Rectangle& rRect)
+{
+ CompleteRedraw(&rWin, rRect);
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void ClientView::CompleteRedraw(OutputDevice* pOutDev, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector )
+{
+ DrawView::CompleteRedraw(pOutDev, rReg, pRedirector);
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drawview.cxx b/sd/source/ui/view/drawview.cxx
new file mode 100755
index 000000000000..f42eba5af17b
--- /dev/null
+++ b/sd/source/ui/view/drawview.cxx
@@ -0,0 +1,651 @@
+ /*************************************************************************
+ *
+ * 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 <sfx2/dispatch.hxx>
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#include <svx/svdpagv.hxx>
+#include <sfx2/request.hxx>
+#include <svl/style.hxx>
+#include <editeng/outliner.hxx>
+#ifndef _VIEW3D_HXX //autogen
+#include <svx/view3d.hxx>
+#endif
+#ifndef _SVXIDS_HRC //autogen
+#include <svx/svxids.hrc>
+#endif
+#include <svx/svdotext.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdorect.hxx>
+#include <svl/poolitem.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/bulitem.hxx>
+#include <svl/itempool.hxx>
+#include <editeng/numitem.hxx>
+#include <svl/whiter.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objface.hxx>
+#include "stlsheet.hxx"
+
+#include <svx/svdoutl.hxx>
+#undef BMP_OLEOBJ
+#include <svx/svdstr.hrc>
+#include <svx/dialmgr.hxx>
+
+#include "glob.hrc"
+#include "strings.hrc"
+#include "View.hxx"
+#include "sdattr.hxx"
+#include "drawview.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "sdpage.hxx"
+#include "DrawViewShell.hxx"
+#include "pres.hxx"
+#include "sdresid.hxx"
+#include "Window.hxx"
+#include "unchss.hxx"
+#ifndef SD_FRAME_VIEW
+#include "FrameView.hxx"
+#endif
+#include "anminfo.hxx"
+#include "slideshow.hxx"
+#include <vcl/virdev.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+
+#include "undo/undomanager.hxx"
+
+using namespace ::com::sun::star;
+
+namespace sd {
+
+TYPEINIT1(DrawView, View);
+
+/*************************************************************************
+|*
+|* Konstruktor
+|* zeigt die erste Seite des Dokuments auf Position 0,0 an;
+|* falls noch keine Seite vorhanden ist, wird eine erzeugt
+|*
+\************************************************************************/
+
+DrawView::DrawView( DrawDocShell* pDocSh, OutputDevice* pOutDev, DrawViewShell* pShell)
+: ::sd::View(pDocSh->GetDoc(), pOutDev, pShell)
+, mpDocShell(pDocSh)
+, mpDrawViewShell(pShell)
+, mpVDev(NULL)
+, mnPOCHSmph(0)
+{
+ SetCurrentObj(OBJ_RECT, SdrInventor);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+DrawView::~DrawView()
+{
+ delete mpVDev;
+}
+
+/*************************************************************************
+|*
+|* virtuelle Methode von SdrView, wird bei Selektionsaenderung gerufen
+|*
+\************************************************************************/
+
+void DrawView::MarkListHasChanged()
+{
+ ::sd::View::MarkListHasChanged();
+
+ if (mpDrawViewShell)
+ mpDrawViewShell->SelectionHasChanged();
+}
+
+/*************************************************************************
+|*
+|* virtuelle Methode von SdrView, wird bei Modelaenderung gerufen
+|*
+\************************************************************************/
+
+void DrawView::ModelHasChanged()
+{
+ ::sd::View::ModelHasChanged();
+
+ // den Gestalter zur Neudarstellung zwingen
+ SfxStyleSheetBasePool* pSSPool = mpDoc->GetStyleSheetPool();
+ pSSPool->Broadcast(SfxStyleSheetPoolHint(SFX_STYLESHEETPOOL_CHANGES));
+
+ if( mpDrawViewShell )
+ mpDrawViewShell->ModelHasChanged();
+
+}
+
+/*************************************************************************
+|*
+|* Attribute auf Titel- und Gliederungtext und Hintergrundrechteck einer
+|* Masterpage in Vorlagen umlenken, sonst an Basisklasse weitergeben
+|*
+\************************************************************************/
+
+sal_Bool DrawView::SetAttributes(const SfxItemSet& rSet,
+ sal_Bool bReplaceAll)
+{
+ sal_Bool bOk = sal_False;
+
+ // wird eine Masterpage bearbeitet?
+ if ( mpDrawViewShell && mpDrawViewShell->GetEditMode() == EM_MASTERPAGE )
+ {
+ SfxStyleSheetBasePool* pStShPool = mpDoc->GetStyleSheetPool();
+ SdPage& rPage = *mpDrawViewShell->getCurrentPage();
+ String aLayoutName = rPage.GetName();
+ SdrTextObj* pEditObject = static_cast< SdrTextObj* >( GetTextEditObject() );
+
+ if (pEditObject)
+ {
+ // Textedit
+ String aTemplateName(aLayoutName);
+
+ sal_uInt32 nInv = pEditObject->GetObjInventor();
+
+ if (nInv == SdrInventor)
+ {
+ sal_uInt16 eObjKind = pEditObject->GetObjIdentifier();
+ PresObjKind ePresObjKind = rPage.GetPresObjKind(pEditObject);
+
+ if ( ePresObjKind == PRESOBJ_TITLE ||
+ ePresObjKind == PRESOBJ_NOTES )
+ {
+ // Presentation object (except outline)
+ SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj( ePresObjKind );
+ DBG_ASSERT(pSheet, "StyleSheet nicht gefunden");
+
+ SfxItemSet aTempSet( pSheet->GetItemSet() );
+ aTempSet.Put( rSet );
+ aTempSet.ClearInvalidItems();
+
+ // Undo-Action
+ StyleSheetUndoAction* pAction = new StyleSheetUndoAction(mpDoc, pSheet, &aTempSet);
+ mpDocSh->GetUndoManager()->AddUndoAction(pAction);
+
+ pSheet->GetItemSet().Put(aTempSet);
+ pSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
+ bOk = sal_True;
+ }
+ else if (eObjKind == OBJ_OUTLINETEXT)
+ {
+ // Presentation object outline
+ OutlinerView* pOV = GetTextEditOutlinerView();
+ ::Outliner* pOutliner = pOV->GetOutliner();
+ List* pList = (List*)pOV->CreateSelectionList();
+ aTemplateName += String(SdResId(STR_LAYOUT_OUTLINE));
+
+ pOutliner->SetUpdateMode(sal_False);
+ mpDocSh->SetWaitCursor( sal_True );
+
+ // Platzhalter durch Vorlagennamen ersetzen
+ String aComment(SdResId(STR_UNDO_CHANGE_PRES_OBJECT));
+ xub_StrLen nPos = aComment.Search( (sal_Unicode)'$' );
+ aComment.Erase(nPos, 1);
+ aComment.Insert( String((SdResId(STR_PSEUDOSHEET_OUTLINE))), nPos);
+ mpDocSh->GetUndoManager()->EnterListAction( aComment, String() );
+
+ Paragraph* pPara = (Paragraph*)pList->Last();
+ while (pPara)
+ {
+ sal_uLong nParaPos = pOutliner->GetAbsPos( pPara );
+ sal_Int16 nDepth = pOutliner->GetDepth( (sal_uInt16) nParaPos );
+ String aName(rPage.GetLayoutName());
+ aName += (sal_Unicode)(' ');
+ aName += String::CreateFromInt32( (nDepth <= 0) ? 1 : nDepth + 1 );
+ SfxStyleSheet* pSheet = (SfxStyleSheet*)pStShPool->Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
+ DBG_ASSERT(pSheet, "StyleSheet nicht gefunden");
+
+ SfxItemSet aTempSet( pSheet->GetItemSet() );
+ aTempSet.Put( rSet );
+ aTempSet.ClearInvalidItems();
+
+ if( nDepth > 0 && aTempSet.GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON )
+ {
+ // no SvxNumBulletItem in outline level 1 to 8!
+ aTempSet.ClearItem( EE_PARA_NUMBULLET );
+ }
+
+ // Undo-Action
+ StyleSheetUndoAction* pAction = new StyleSheetUndoAction(mpDoc, pSheet, &aTempSet);
+ mpDocSh->GetUndoManager()->AddUndoAction(pAction);
+
+ pSheet->GetItemSet().Put(aTempSet);
+ pSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
+
+ // now also broadcast any child sheets
+ sal_Int16 nChild;
+ for( nChild = nDepth + 1; nChild < 9; nChild++ )
+ {
+ String aSheetName(rPage.GetLayoutName());
+ aSheetName += (sal_Unicode)(' ');
+ aSheetName += String::CreateFromInt32( nChild <= 0 ? 1 : nChild + 1 );
+ SfxStyleSheet* pOutlSheet = static_cast< SfxStyleSheet* >(pStShPool->Find(aSheetName, SD_STYLE_FAMILY_MASTERPAGE));
+
+ if( pOutlSheet )
+ pOutlSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
+ }
+
+ pPara = (Paragraph*)pList->Prev();
+
+ if( !pPara && nDepth > 0 && rSet.GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON &&
+ pOutliner->GetDepth( (sal_uInt16) pOutliner->GetAbsPos( (Paragraph*) pList->First() ) ) > 0 )
+ pPara = pOutliner->GetParagraph( 0 ); // Put NumBulletItem in outline level 1
+ }
+
+ mpDocSh->SetWaitCursor( sal_False );
+ pOV->GetOutliner()->SetUpdateMode(sal_True);
+
+ mpDocSh->GetUndoManager()->LeaveListAction();
+
+ delete pList;
+ bOk = sal_True;
+ }
+ else
+ {
+ bOk = ::sd::View::SetAttributes(rSet, bReplaceAll);
+ }
+ }
+ }
+ else
+ {
+ // Selection
+ const SdrMarkList& rList = GetMarkedObjectList();
+ sal_uLong nMarkCount = rList.GetMarkCount();
+ for (sal_uLong nMark = 0; nMark < nMarkCount; nMark++)
+ {
+ SdrObject* pObject = rList.GetMark(nMark)->GetMarkedSdrObj();
+ sal_uInt32 nInv = pObject->GetObjInventor();
+
+ if (nInv == SdrInventor)
+ {
+ sal_uInt16 eObjKind = pObject->GetObjIdentifier();
+ PresObjKind ePresObjKind = rPage.GetPresObjKind(pObject);
+ String aTemplateName(aLayoutName);
+
+ if (ePresObjKind == PRESOBJ_TITLE ||
+ ePresObjKind == PRESOBJ_NOTES)
+ {
+ // Presentation object (except outline)
+ SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj( ePresObjKind );
+ DBG_ASSERT(pSheet, "StyleSheet not found");
+
+ SfxItemSet aTempSet( pSheet->GetItemSet() );
+ aTempSet.Put( rSet );
+ aTempSet.ClearInvalidItems();
+
+ // Undo-Action
+ StyleSheetUndoAction* pAction = new StyleSheetUndoAction(mpDoc, pSheet, &aTempSet);
+ mpDocSh->GetUndoManager()->AddUndoAction(pAction);
+
+ pSheet->GetItemSet().Put(aTempSet,false);
+ pSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
+ bOk = sal_True;
+ }
+ else if (eObjKind == OBJ_OUTLINETEXT)
+ {
+ // Presentation object outline
+ aTemplateName += String(SdResId(STR_LAYOUT_OUTLINE));
+ for (sal_uInt16 nLevel = 9; nLevel > 0; nLevel--)
+ {
+ String aName(rPage.GetLayoutName());
+ aName += (sal_Unicode)(' ');
+ aName += String::CreateFromInt32( (sal_Int32)nLevel );
+ SfxStyleSheet* pSheet = (SfxStyleSheet*)pStShPool->
+ Find(aName, SD_STYLE_FAMILY_MASTERPAGE);
+ DBG_ASSERT(pSheet, "StyleSheet nicht gefunden");
+
+ SfxItemSet aTempSet( pSheet->GetItemSet() );
+
+ if( nLevel > 1 )
+ {
+ // for all levels over 1, clear all items that will be
+ // hard set to level 1
+ SfxWhichIter aWhichIter(rSet);
+ sal_uInt16 nWhich(aWhichIter.FirstWhich());
+ while( nWhich )
+ {
+ if( SFX_ITEM_ON == rSet.GetItemState( nWhich ) )
+ aTempSet.ClearItem( nWhich );
+ nWhich = aWhichIter.NextWhich();
+ }
+
+ }
+ else
+ {
+ // put the items hard into level one
+ aTempSet.Put( rSet );
+ }
+
+ aTempSet.ClearInvalidItems();
+
+ // Undo-Action
+ StyleSheetUndoAction* pAction = new StyleSheetUndoAction(mpDoc, pSheet, &aTempSet);
+ mpDocSh->GetUndoManager()->AddUndoAction(pAction);
+
+ pSheet->GetItemSet().Set(aTempSet,false);
+ pSheet->Broadcast(SfxSimpleHint(SFX_HINT_DATACHANGED));
+ }
+
+ // remove all hard set items from shape that are now set in style
+ SfxWhichIter aWhichIter(rSet);
+ sal_uInt16 nWhich(aWhichIter.FirstWhich());
+ while( nWhich )
+ {
+ if( SFX_ITEM_ON == rSet.GetItemState( nWhich ) )
+ pObject->ClearMergedItem( nWhich );
+ nWhich = aWhichIter.NextWhich();
+ }
+
+ bOk = sal_True;
+ }
+ }
+ }
+
+ if(!bOk)
+ bOk = ::sd::View::SetAttributes(rSet, bReplaceAll);
+ }
+ }
+ else // nicht auf der Masterpage
+ {
+ bOk = ::sd::View::SetAttributes(rSet, bReplaceAll);
+ }
+
+ return (bOk);
+}
+
+/*************************************************************************
+|*
+|* Notify fuer Aenderung der Seitenanordnung
+|*
+\************************************************************************/
+
+void DrawView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
+{
+ if ( mpDrawViewShell && rHint.ISA(SdrHint) )
+ {
+ SdrHintKind eHintKind = ( (SdrHint&) rHint).GetKind();
+
+ if ( mnPOCHSmph == 0 && eHintKind == HINT_PAGEORDERCHG )
+ {
+ mpDrawViewShell->ResetActualPage();
+ }
+ else if ( eHintKind == HINT_LAYERCHG || eHintKind == HINT_LAYERORDERCHG )
+ {
+ mpDrawViewShell->ResetActualLayer();
+ }
+
+ // #94278# switch to that page when it's not a master page
+ if(HINT_SWITCHTOPAGE == eHintKind)
+ {
+ const SdrPage* pPage = ((const SdrHint&)rHint).GetPage();
+
+ if(pPage && !pPage->IsMasterPage())
+ {
+ if(mpDrawViewShell->GetActualPage() != pPage)
+ {
+ sal_uInt16 nPageNum = (pPage->GetPageNum() - 1) / 2; // Sdr --> Sd
+ mpDrawViewShell->SwitchPage(nPageNum);
+ }
+ }
+ }
+ }
+
+ ::sd::View::Notify(rBC, rHint);
+}
+
+/*************************************************************************
+|*
+|* PageOrderChangedHint blockieren/freigeben
+|*
+\************************************************************************/
+
+void DrawView::BlockPageOrderChangedHint(sal_Bool bBlock)
+{
+ if (bBlock)
+ mnPOCHSmph++;
+ else
+ {
+ DBG_ASSERT(mnPOCHSmph, "Zaehlerunterlauf");
+ mnPOCHSmph--;
+ }
+}
+
+/*************************************************************************
+|*
+|* StyleSheet-Setzen auf der Masterpage abfangen, wenn Praesentationsobjekte
+|* selektiert sind
+|*
+\************************************************************************/
+
+sal_Bool DrawView::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
+{
+ sal_Bool bResult = sal_True;
+
+ // wird eine Masterpage bearbeitet?
+ if (mpDrawViewShell && mpDrawViewShell->GetEditMode() == EM_MASTERPAGE)
+ {
+ if (IsPresObjSelected(sal_False, sal_True))
+ {
+
+ InfoBox(mpDrawViewShell->GetActiveWindow(),
+ String(SdResId(STR_ACTION_NOTPOSSIBLE))).Execute();
+ bResult = sal_False;
+ }
+ else
+ {
+ bResult = ::sd::View::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
+ }
+ }
+ else
+ {
+ bResult = ::sd::View::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
+ }
+ return bResult;
+}
+
+/*************************************************************************
+|*
+|* Paint-Methode: das Ereignis wird an die View weitergeleitet
+|*
+\************************************************************************/
+
+void DrawView::CompleteRedraw(OutputDevice* pOutDev, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector /*=0L*/)
+{
+ if( mpVDev )
+ {
+ delete mpVDev;
+ mpVDev = NULL;
+ }
+
+ sal_Bool bStandardPaint = sal_True;
+
+ SdDrawDocument* pDoc = mpDocShell->GetDoc();
+ if( pDoc && pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS)
+ {
+ rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( pDoc ) );
+ if(xSlideshow.is() && xSlideshow->isRunning())
+ {
+ OutputDevice* pShowWindow = ( OutputDevice* )xSlideshow->getShowWindow();
+ if( (pShowWindow == pOutDev) || (xSlideshow->getAnimationMode() == ANIMATIONMODE_PREVIEW) )
+ {
+ if( pShowWindow == pOutDev )
+ PresPaint(rReg);
+ bStandardPaint = sal_False;
+ }
+ }
+ }
+
+ if(bStandardPaint)
+ {
+ ::sd::View::CompleteRedraw(pOutDev, rReg, pRedirector);
+ }
+}
+
+/*************************************************************************
+|*
+|* Paint-Event during running slide show
+|*
+\************************************************************************/
+
+void DrawView::PresPaint(const Region& rRegion)
+{
+ if(mpViewSh)
+ {
+ rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
+ if( xSlideshow.is() && xSlideshow->isRunning() )
+ xSlideshow->paint( rRegion.GetBoundRect() );
+ }
+}
+
+/*************************************************************************
+|* entscheidet, ob ein Objekt markiert werden kann (z. B. noch nicht
+|* erschienene Animationsobjekte in der Diashow)
+\************************************************************************/
+
+sal_Bool DrawView::IsObjMarkable(SdrObject* pObj, SdrPageView* pPV) const
+{
+ return FmFormView::IsObjMarkable(pObj, pPV);;
+}
+
+/*************************************************************************
+|*
+|* Uebergebenen Bereich sichtbar machen (es wird ggf. gescrollt)
+|*
+\************************************************************************/
+
+void DrawView::MakeVisible(const Rectangle& rRect, ::Window& rWin)
+{
+ if (!rRect.IsEmpty())
+ {
+ mpDrawViewShell->MakeVisible(rRect, rWin);
+ }
+}
+/*************************************************************************
+|*
+|* Seite wird gehided
+|*
+\************************************************************************/
+
+void DrawView::HideSdrPage()
+{
+ if (mpDrawViewShell)
+ {
+ mpDrawViewShell->HidePage();
+ }
+
+ ::sd::View::HideSdrPage();
+}
+
+void DrawView::DeleteMarked()
+{
+ OSL_TRACE( "DrawView::DeleteMarked() - enter" );
+
+ sd::UndoManager* pUndoManager = mpDoc->GetUndoManager();
+ DBG_ASSERT( pUndoManager, "sd::DrawView::DeleteMarked(), ui action without undo manager!?" );
+
+ if( pUndoManager )
+ {
+ String aUndo( SVX_RES(STR_EditDelete) );
+ String aSearchString(RTL_CONSTASCII_USTRINGPARAM("%1"));
+ aUndo.SearchAndReplace(aSearchString, GetDescriptionOfMarkedObjects());
+ pUndoManager->EnterListAction(aUndo, aUndo);
+ }
+
+ SdPage* pPage = 0;
+ bool bResetLayout = false;
+
+ const sal_uLong nMarkCount = GetMarkedObjectList().GetMarkCount();
+ if( nMarkCount )
+ {
+ SdrMarkList aList( GetMarkedObjectList() );
+ for (sal_uLong nMark = 0; nMark < nMarkCount; nMark++)
+ {
+ SdrObject* pObj = aList.GetMark(nMark)->GetMarkedSdrObj();
+ if( pObj && !pObj->IsEmptyPresObj() && pObj->GetUserCall() )
+ {
+ pPage = static_cast< SdPage* >( pObj->GetPage() );
+ PresObjKind ePresObjKind;
+ if( pPage && ((ePresObjKind = pPage->GetPresObjKind(pObj)) != PRESOBJ_NONE))
+ {
+ switch( ePresObjKind )
+ {
+ case PRESOBJ_GRAPHIC:
+ case PRESOBJ_OBJECT:
+ case PRESOBJ_CHART:
+ case PRESOBJ_ORGCHART:
+ case PRESOBJ_TABLE:
+ case PRESOBJ_CALC:
+ case PRESOBJ_IMAGE:
+ case PRESOBJ_MEDIA:
+ ePresObjKind = PRESOBJ_OUTLINE;
+ break;
+ default:
+ break;
+ }
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
+ bool bVertical = pTextObj && pTextObj->IsVerticalWriting();
+ Rectangle aRect( pObj->GetLogicRect() );
+ SdrObject* pNewObj = pPage->InsertAutoLayoutShape( 0, ePresObjKind, bVertical, aRect, true );
+
+ pPage->SetObjectOrdNum( pNewObj->GetOrdNum(), pObj->GetOrdNum() );
+
+ bResetLayout = true;
+
+ OSL_TRACE( "DrawView::InsertAutoLayoutShape() - InsertAutoLayoutShape" );
+ }
+ }
+ }
+ }
+
+ ::sd::View::DeleteMarked();
+
+ if( pPage && bResetLayout )
+ pPage->SetAutoLayout( pPage->GetAutoLayout() );
+
+ if( pUndoManager )
+ pUndoManager->LeaveListAction();
+
+ OSL_TRACE( "DrawView::InsertAutoLayoutShape() - leave" );
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drbezob.cxx b/sd/source/ui/view/drbezob.cxx
new file mode 100755
index 000000000000..0d7bcfb47ad3
--- /dev/null
+++ b/sd/source/ui/view/drbezob.cxx
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * 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 "BezierObjectBar.hxx"
+#include <sfx2/app.hxx>
+#include <sfx2/msg.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/objface.hxx>
+
+#include <svx/svxids.hrc>
+#include <svl/eitem.hxx>
+#include <sfx2/request.hxx>
+#include <svx/svdopath.hxx>
+#include <svl/aeitem.hxx>
+#include <svx/svdundo.hxx>
+#include <sfx2/dispatch.hxx>
+
+
+#include "sdresid.hxx"
+
+
+
+#include "res_bmp.hrc"
+#include "glob.hrc"
+#include "strings.hrc"
+
+#include "DrawDocShell.hxx"
+#include "ViewShell.hxx"
+#include "Window.hxx"
+#include "drawview.hxx"
+#include "drawdoc.hxx"
+#include "sdresid.hxx"
+#include "fusel.hxx"
+#include "fuconbez.hxx"
+
+
+using namespace sd;
+#define BezierObjectBar
+#include "sdslots.hxx"
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Standardinterface deklarieren (Die Slotmap darf nicht leer sein)
+|*
+\************************************************************************/
+
+
+
+SFX_IMPL_INTERFACE(BezierObjectBar, ::SfxShell, SdResId(STR_BEZIEROBJECTBARSHELL))
+{
+}
+
+TYPEINIT1(BezierObjectBar, ::SfxShell);
+
+/*************************************************************************
+|*
+|* Standard-Konstruktor
+|*
+\************************************************************************/
+
+BezierObjectBar::BezierObjectBar(
+ ViewShell* pSdViewShell,
+ ::sd::View* pSdView)
+ : SfxShell(pSdViewShell->GetViewShell()),
+ mpView(pSdView),
+ mpViewSh(pSdViewShell)
+{
+ DrawDocShell* pDocShell = mpViewSh->GetDocSh();
+ SetPool(&pDocShell->GetPool());
+ SetUndoManager(pDocShell->GetUndoManager());
+ SetRepeatTarget(mpView);
+
+ SetHelpId( SD_IF_SDDRAWBEZIEROBJECTBAR );
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+BezierObjectBar::~BezierObjectBar()
+{
+ SetRepeatTarget(NULL);
+}
+
+
+/*************************************************************************
+|*
+|* Status der Attribut-Items
+|*
+\************************************************************************/
+
+void BezierObjectBar::GetAttrState(SfxItemSet& rSet)
+{
+ SfxItemSet aAttrSet( mpView->GetDoc()->GetPool() );
+ mpView->GetAttributes( aAttrSet );
+ rSet.Put(aAttrSet, sal_False); // <- sal_False, damit DontCare-Status uebernommen wird
+
+ FunctionReference xFunc( mpViewSh->GetCurrentFunction() );
+
+ if(xFunc.is())
+ {
+ if(xFunc->ISA(FuSelection))
+ {
+ sal_uInt16 nEditMode = static_cast<FuSelection*>(xFunc.get())->GetEditMode();
+ rSet.Put(SfxBoolItem(nEditMode, sal_True));
+ }
+ else if (xFunc->ISA(FuConstructBezierPolygon))
+ {
+ sal_uInt16 nEditMode = static_cast<FuConstructBezierPolygon*>(xFunc.get())->GetEditMode();
+ rSet.Put(SfxBoolItem(nEditMode, sal_True));
+ }
+ }
+
+ if(!mpView->IsMoveAllowed() || !mpView->IsResizeAllowed())
+ {
+ // #i77187# if object is move and/or size protected, do not allow point editing at all
+ rSet.DisableItem(SID_BEZIER_MOVE);
+ rSet.DisableItem(SID_BEZIER_INSERT);
+
+ rSet.DisableItem(SID_BEZIER_DELETE);
+ rSet.DisableItem(SID_BEZIER_CUTLINE);
+ rSet.DisableItem(SID_BEZIER_CONVERT);
+
+ rSet.DisableItem(SID_BEZIER_EDGE);
+ rSet.DisableItem(SID_BEZIER_SMOOTH);
+ rSet.DisableItem(SID_BEZIER_SYMMTR);
+
+ rSet.DisableItem(SID_BEZIER_CLOSE);
+
+ rSet.DisableItem(SID_BEZIER_ELIMINATE_POINTS);
+ }
+ else
+ {
+ IPolyPolygonEditorController* pIPPEC = 0;
+ if( mpView->GetMarkedObjectList().GetMarkCount() )
+ pIPPEC = mpView;
+ else
+ pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
+
+ if ( !pIPPEC || !pIPPEC->IsRipUpAtMarkedPointsPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_CUTLINE);
+ }
+ if (!pIPPEC || !pIPPEC->IsDeleteMarkedPointsPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_DELETE);
+ }
+ if (!pIPPEC || !pIPPEC->IsSetMarkedSegmentsKindPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_CONVERT);
+ }
+ else
+ {
+ SdrPathSegmentKind eSegm = pIPPEC->GetMarkedSegmentsKind();
+ switch (eSegm)
+ {
+ case SDRPATHSEGMENT_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CONVERT); break;
+ case SDRPATHSEGMENT_LINE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_False)); break; // Button reingedrueckt = Kurve
+ case SDRPATHSEGMENT_CURVE : rSet.Put(SfxBoolItem(SID_BEZIER_CONVERT,sal_True)); break;
+ default: break;
+ }
+ }
+ if (!pIPPEC || !pIPPEC->IsSetMarkedPointsSmoothPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_EDGE);
+ rSet.DisableItem(SID_BEZIER_SMOOTH);
+ rSet.DisableItem(SID_BEZIER_SYMMTR);
+ }
+ else
+ {
+ SdrPathSmoothKind eSmooth = pIPPEC->GetMarkedPointsSmooth();
+ switch (eSmooth)
+ {
+ case SDRPATHSMOOTH_DONTCARE : break;
+ case SDRPATHSMOOTH_ANGULAR : rSet.Put(SfxBoolItem(SID_BEZIER_EDGE, sal_True)); break;
+ case SDRPATHSMOOTH_ASYMMETRIC: rSet.Put(SfxBoolItem(SID_BEZIER_SMOOTH,sal_True)); break;
+ case SDRPATHSMOOTH_SYMMETRIC : rSet.Put(SfxBoolItem(SID_BEZIER_SYMMTR,sal_True)); break;
+ }
+ }
+ if (!pIPPEC || !pIPPEC->IsOpenCloseMarkedObjectsPossible())
+ {
+ rSet.DisableItem(SID_BEZIER_CLOSE);
+ }
+ else
+ {
+ SdrObjClosedKind eClose = pIPPEC->GetMarkedObjectsClosedState();
+ switch (eClose)
+ {
+ case SDROBJCLOSED_DONTCARE: rSet.InvalidateItem(SID_BEZIER_CLOSE); break;
+ case SDROBJCLOSED_OPEN : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_False)); break;
+ case SDROBJCLOSED_CLOSED : rSet.Put(SfxBoolItem(SID_BEZIER_CLOSE,sal_True)); break;
+ default: break;
+ }
+ }
+
+ if(pIPPEC == mpView)
+ rSet.Put(SfxBoolItem(SID_BEZIER_ELIMINATE_POINTS, mpView->IsEliminatePolyPoints()));
+ else
+ rSet.DisableItem( SID_BEZIER_ELIMINATE_POINTS ); // only works for views
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Bearbeitung der SfxRequests
+|*
+\************************************************************************/
+
+void BezierObjectBar::Execute(SfxRequest& rReq)
+{
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ switch (nSId)
+ {
+ case SID_BEZIER_CUTLINE:
+ case SID_BEZIER_CONVERT:
+ case SID_BEZIER_DELETE:
+ case SID_BEZIER_EDGE:
+ case SID_BEZIER_SMOOTH:
+ case SID_BEZIER_SYMMTR:
+ case SID_BEZIER_CLOSE:
+ {
+ const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+
+ IPolyPolygonEditorController* pIPPEC = 0;
+ if( rMarkList.GetMarkCount() )
+ pIPPEC = mpView;
+ else
+ pIPPEC = dynamic_cast< IPolyPolygonEditorController* >( mpView->getSmartTags().getSelected().get() );
+
+ if( pIPPEC && !mpView->IsAction())
+ {
+ switch (nSId)
+ {
+ case SID_BEZIER_DELETE:
+ pIPPEC->DeleteMarkedPoints();
+ break;
+
+ case SID_BEZIER_CUTLINE:
+ pIPPEC->RipUpAtMarkedPoints();
+ break;
+
+ case SID_BEZIER_CONVERT:
+ {
+ pIPPEC->SetMarkedSegmentsKind(SDRPATHSEGMENT_TOGGLE);
+ break;
+ }
+
+ case SID_BEZIER_EDGE:
+ case SID_BEZIER_SMOOTH:
+ case SID_BEZIER_SYMMTR:
+ {
+ SdrPathSmoothKind eKind;
+
+ switch (nSId)
+ {
+ default:
+ case SID_BEZIER_EDGE: eKind = SDRPATHSMOOTH_ANGULAR; break;
+ case SID_BEZIER_SMOOTH: eKind = SDRPATHSMOOTH_ASYMMETRIC; break;
+ case SID_BEZIER_SYMMTR: eKind = SDRPATHSMOOTH_SYMMETRIC; break;
+ }
+
+ pIPPEC->SetMarkedPointsSmooth(eKind);
+ break;
+ }
+
+ case SID_BEZIER_CLOSE:
+ {
+ SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
+ const bool bUndo = mpView->IsUndoEnabled();
+ if( bUndo )
+ mpView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
+
+ mpView->UnmarkAllPoints();
+
+ if( bUndo )
+ mpView->AddUndo(mpView->GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pPathObj));
+
+ pPathObj->ToggleClosed();
+
+ if( bUndo )
+ mpView->EndUndo();
+ break;
+ }
+ }
+ }
+
+ if( (pIPPEC == mpView) && !mpView->AreObjectsMarked() )
+ mpViewSh->GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_BEZIER_ELIMINATE_POINTS:
+ {
+ mpView->SetEliminatePolyPoints(!mpView->IsEliminatePolyPoints());
+ Invalidate(SID_BEZIER_ELIMINATE_POINTS);
+ rReq.Done();
+ }
+ break;
+
+ case SID_BEZIER_MOVE:
+ case SID_BEZIER_INSERT:
+ {
+ FunctionReference xFunc( mpViewSh->GetCurrentFunction() );
+
+ if(xFunc.is())
+ {
+ if(xFunc->ISA(FuSelection))
+ {
+ static_cast<FuSelection*>(xFunc.get())->SetEditMode(rReq.GetSlot());
+ }
+ else if(xFunc->ISA(FuConstructBezierPolygon))
+ {
+ static_cast<FuConstructBezierPolygon*>(xFunc.get())->SetEditMode(rReq.GetSlot());
+ }
+ }
+
+ rReq.Ignore ();
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ Invalidate();
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx
new file mode 100755
index 000000000000..4f1ddccdb5c8
--- /dev/null
+++ b/sd/source/ui/view/drtxtob.cxx
@@ -0,0 +1,591 @@
+/*************************************************************************
+ *
+ * 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 "TextObjectBar.hxx"
+
+#include <svx/svxids.hrc>
+
+#include <i18npool/mslangid.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/adjitem.hxx>
+#include <editeng/editview.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/adjitem.hxx>
+#include <vcl/vclenum.hxx>
+#include <sfx2/app.hxx>
+#include <svl/whiter.hxx>
+#include <svl/itempool.hxx>
+#include <svl/stritem.hxx>
+#include <svl/style.hxx>
+#include <svl/languageoptions.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <editeng/escpitem.hxx>
+#include <svx/svdoutl.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <editeng/frmdiritem.hxx>
+
+
+#include <sfx2/objface.hxx>
+
+#include "app.hrc"
+#include "glob.hrc"
+#include "res_bmp.hrc"
+
+#include "eetext.hxx"
+
+#include "drawdoc.hxx"
+#include "DrawViewShell.hxx"
+#include "OutlineViewShell.hxx"
+#include "ViewShellBase.hxx"
+#include "ToolBarManager.hxx"
+#include "futempl.hxx"
+#include "sdresid.hxx"
+#include "Window.hxx"
+#include "OutlineView.hxx"
+
+
+using namespace sd;
+using namespace ::com::sun::star;
+
+#define TextObjectBar
+#include "sdslots.hxx"
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Standardinterface deklarieren (Die Slotmap darf nicht leer sein, also
+|* tragen wir etwas ein, was hier (hoffentlich) nie vorkommt).
+|*
+\************************************************************************/
+
+
+SFX_IMPL_INTERFACE( TextObjectBar, SfxShell, SdResId(STR_TEXTOBJECTBARSHELL) )
+{
+}
+
+TYPEINIT1( TextObjectBar, SfxShell );
+
+/*************************************************************************
+|*
+|* Standard-Konstruktor
+|*
+\************************************************************************/
+
+TextObjectBar::TextObjectBar (
+ ViewShell* pSdViewSh,
+ SfxItemPool& rItemPool,
+ ::sd::View* pSdView )
+ : SfxShell(pSdViewSh->GetViewShell()),
+ mpViewShell( pSdViewSh ),
+ mpView( pSdView )
+{
+ SetPool(&rItemPool);
+
+ if( mpView )
+ {
+ OutlineView* pOutlinerView = dynamic_cast< OutlineView* >( mpView );
+ if( pOutlinerView )
+ {
+ SetUndoManager(&pOutlinerView->GetOutliner()->GetUndoManager());
+ }
+ else
+ {
+ SdDrawDocument* pDoc = mpView->GetDoc();
+ if( pDoc )
+ {
+ DrawDocShell* pDocShell = pDoc->GetDocSh();
+ if( pDocShell )
+ {
+ SetUndoManager(pDocShell->GetUndoManager());
+ DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( pSdViewSh );
+ if ( pDrawViewShell )
+ SetRepeatTarget(pSdView);
+ }
+ }
+ }
+ }
+
+ SetName( String( RTL_CONSTASCII_USTRINGPARAM( "TextObjectBar" )));
+
+ // SetHelpId( SD_IF_SDDRAWTEXTOBJECTBAR );
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+TextObjectBar::~TextObjectBar()
+{
+ SetRepeatTarget(NULL);
+}
+
+/*************************************************************************
+|*
+|* Status der Attribut-Items
+|*
+\************************************************************************/
+
+void TextObjectBar::GetAttrState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ sal_Bool bTemplate = sal_False;
+ SfxItemSet aAttrSet( mpView->GetDoc()->GetPool() );
+ SvtLanguageOptions aLangOpt;
+ sal_Bool bDisableParagraphTextDirection = !aLangOpt.IsCTLFontEnabled();
+ sal_Bool bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled();
+
+ mpView->GetAttributes( aAttrSet );
+
+ while ( nWhich )
+ {
+ sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
+ ? GetPool().GetSlotId(nWhich)
+ : nWhich;
+
+ switch ( nSlotId )
+ {
+ case SID_ATTR_CHAR_FONT:
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ case SID_ATTR_CHAR_WEIGHT:
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ SvxScriptSetItem aSetItem( nSlotId, GetPool() );
+ aSetItem.GetItemSet().Put( aAttrSet, sal_False );
+
+ sal_uInt16 nScriptType = mpView->GetScriptType();
+
+ if( (nSlotId == SID_ATTR_CHAR_FONT) || (nSlotId == SID_ATTR_CHAR_FONTHEIGHT) )
+ {
+ // #42732# input language should be preferred over
+ // current cursor position to detect script type
+ OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+
+ if (mpView->ISA(OutlineView))
+ {
+ pOLV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
+ mpViewShell->GetActiveWindow());
+ }
+
+ if(pOLV && !pOLV->GetSelection().HasRange())
+ {
+ if( mpViewShell && mpViewShell->GetViewShell() && mpViewShell->GetViewShell()->GetWindow() )
+ {
+ LanguageType nInputLang = mpViewShell->GetViewShell()->GetWindow()->GetInputLanguage();
+ if(nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM)
+ nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang );
+ }
+ }
+ }
+
+ const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
+ if( pI )
+ aAttrSet.Put( *pI, nWhich );
+ else
+ aAttrSet.InvalidateItem( nWhich );
+ }
+ break;
+
+
+ case SID_STYLE_APPLY:
+ case SID_STYLE_FAMILY2:
+ {
+ SfxStyleSheet* pStyleSheet = mpView->GetStyleSheetFromMarked();
+ if( pStyleSheet )
+ rSet.Put( SfxTemplateItem( nWhich, pStyleSheet->GetName() ) );
+ else
+ {
+ rSet.Put( SfxTemplateItem( nWhich, String() ) );
+ }
+ bTemplate = sal_True;
+ }
+ break;
+
+ case SID_OUTLINE_LEFT:
+ case SID_OUTLINE_RIGHT:
+ case SID_OUTLINE_UP:
+ case SID_OUTLINE_DOWN:
+ {
+ sal_Bool bDisableLeft = sal_True;
+ sal_Bool bDisableRight = sal_True;
+ sal_Bool bDisableUp = sal_True;
+ sal_Bool bDisableDown = sal_True;
+ OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+
+ if (mpView->ISA(OutlineView))
+ {
+ pOLV = static_cast<OutlineView*>(mpView)->GetViewByWindow(
+ mpViewShell->GetActiveWindow());
+ }
+
+ sal_Bool bOutlineViewSh = mpViewShell->ISA(OutlineViewShell);
+
+ if (pOLV &&
+ ( pOLV->GetOutliner()->GetMode() == OUTLINERMODE_OUTLINEOBJECT || bOutlineViewSh ) )
+ {
+ // Outliner im Gliederungsmodus
+ ::Outliner* pOutl = pOLV->GetOutliner();
+ List* pList = pOLV->CreateSelectionList();
+ Paragraph* pPara = (Paragraph*) pList->First();
+
+ // #96539# find out if we are a OutlineView
+ sal_Bool bIsOutlineView(OUTLINERMODE_OUTLINEVIEW == pOLV->GetOutliner()->GetMode());
+
+ // #96539# This is ONLY for OutlineViews
+ if(bIsOutlineView)
+ {
+ // #96250# and #78665#
+ // allow move up if position is 2 or greater OR it
+ // is a title object (and thus depth==1)
+ if(pOutl->GetAbsPos(pPara) > 1 || ( pOutl->HasParaFlag(pPara,PARAFLAG_ISPAGE) && pOutl->GetAbsPos(pPara) > 0 ) )
+ {
+ // Nicht ganz oben
+ bDisableUp = sal_False;
+ }
+ }
+ else
+ {
+ // #96539# old behaviour for OUTLINERMODE_OUTLINEOBJECT
+ if(pOutl->GetAbsPos(pPara) > 0)
+ {
+ // Nicht ganz oben
+ bDisableUp = sal_False;
+ }
+ }
+
+ while (pPara)
+ {
+ sal_Int16 nDepth = pOutl->GetDepth( (sal_uInt16) pOutl->GetAbsPos( pPara ) );
+
+ if (nDepth > 0 || (bOutlineViewSh && (nDepth <= 0) && !pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE )) )
+ {
+ // Nicht minimale Tiefe
+ bDisableLeft = sal_False;
+ }
+
+ if( (nDepth < pOLV->GetOutliner()->GetMaxDepth() && ( !bOutlineViewSh || pOutl->GetAbsPos(pPara) != 0 )) ||
+ (bOutlineViewSh && (nDepth <= 0) && pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && pOutl->GetAbsPos(pPara) != 0) )
+ {
+ // Nicht maximale Tiefe und nicht ganz oben
+ bDisableRight = sal_False;
+ }
+
+ pPara = static_cast<Paragraph*>( pList->Next() );
+ }
+
+ if ( ( pOutl->GetAbsPos((Paragraph*) pList->Last()) < pOutl->GetParagraphCount() - 1 ) &&
+ ( pOutl->GetParagraphCount() > 1 || !bOutlineViewSh) )
+ {
+ // Nicht letzter Absatz
+ bDisableDown = sal_False;
+ }
+
+ // #96250# and #78665#
+ // disable when first para and 2nd is not a title
+ pPara = static_cast< Paragraph* >( pList->First() );
+ if(!bDisableDown && bIsOutlineView
+ && pPara
+ && 0 == pOutl->GetAbsPos(pPara)
+ && pOutl->GetParagraphCount() > 1
+ && !pOutl->HasParaFlag( pOutl->GetParagraph(1), PARAFLAG_ISPAGE ) )
+ {
+ // Needs to be disabled
+ bDisableDown = sal_True;
+ }
+
+ delete pList;
+ }
+
+ if (bDisableLeft)
+ rSet.DisableItem(SID_OUTLINE_LEFT);
+ if (bDisableRight)
+ rSet.DisableItem(SID_OUTLINE_RIGHT);
+ if (bDisableUp)
+ rSet.DisableItem(SID_OUTLINE_UP);
+ if (bDisableDown)
+ rSet.DisableItem(SID_OUTLINE_DOWN);
+ }
+ break;
+
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ {
+ if ( bDisableVerticalText )
+ {
+ rSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
+ rSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
+ }
+ else
+ {
+ sal_Bool bLeftToRight = sal_True;
+
+ SdrOutliner* pOutl = mpView->GetTextEditOutliner();
+ if( pOutl )
+ {
+ if( pOutl->IsVertical() )
+ bLeftToRight = sal_False;
+ }
+ else
+ bLeftToRight = ( (const SvxWritingModeItem&) aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB;
+
+ rSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) );
+ rSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) );
+
+ if( !bLeftToRight )
+ bDisableParagraphTextDirection = sal_True;
+ }
+ }
+ break;
+
+ case SID_GROW_FONT_SIZE:
+ case SID_SHRINK_FONT_SIZE:
+ {
+ // todo
+ }
+ break;
+
+ case SID_THES:
+ {
+ if( mpView && mpView->GetTextEditOutlinerView() )
+ {
+ EditView & rEditView = mpView->GetTextEditOutlinerView()->GetEditView();;
+ String aStatusVal;
+ LanguageType nLang = LANGUAGE_NONE;
+ bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView );
+ rSet.Put( SfxStringItem( SID_THES, aStatusVal ) );
+
+ // disable "Thesaurus" context menu entry if there is nothing to look up
+ lang::Locale aLocale( SvxCreateLocale( nLang ) );
+ uno::Reference< linguistic2::XThesaurus > xThes( LinguMgr::GetThesaurus() );
+ if (!bIsLookUpWord ||
+ !xThes.is() || nLang == LANGUAGE_NONE || !xThes->hasLocale( aLocale ))
+ rSet.DisableItem( SID_THES );
+ }
+ else
+ {
+ rSet.DisableItem( SID_THES );
+ }
+ //! avoid puting the same item as SfxBoolItem at the end of this function
+ nSlotId = 0;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+
+ rSet.Put( aAttrSet, sal_False ); // <- sal_False, damit DontCare-Status uebernommen wird
+
+
+ // die sind im Gliederungsmodus disabled
+ if (!mpViewShell->ISA(DrawViewShell))
+ {
+ rSet.DisableItem( SID_ATTR_PARA_ADJUST_LEFT );
+ rSet.DisableItem( SID_ATTR_PARA_ADJUST_RIGHT );
+ rSet.DisableItem( SID_ATTR_PARA_ADJUST_CENTER );
+ rSet.DisableItem( SID_ATTR_PARA_ADJUST_BLOCK );
+ rSet.DisableItem( SID_ATTR_PARA_LINESPACE_10 );
+ rSet.DisableItem( SID_ATTR_PARA_LINESPACE_15 );
+ rSet.DisableItem( SID_ATTR_PARA_LINESPACE_20 );
+ rSet.DisableItem( SID_PARASPACE_INCREASE );
+ rSet.DisableItem( SID_PARASPACE_DECREASE );
+ rSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM );
+ rSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT );
+ rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ }
+ else
+ {
+ // Absatzabstand
+ OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+ if( pOLV )
+ {
+ ESelection aSel = pOLV->GetSelection();
+ aSel.Adjust();
+ sal_uLong nStartPara = aSel.nStartPara;
+ sal_uLong nEndPara = aSel.nEndPara;
+ if( !aSel.HasRange() )
+ {
+ nStartPara = 0;
+ nEndPara = pOLV->GetOutliner()->GetParagraphCount() - 1;
+ }
+ long nUpper = 0L;
+ for( sal_uLong nPara = nStartPara; nPara <= nEndPara; nPara++ )
+ {
+ const SfxItemSet& rItems = pOLV->GetOutliner()->GetParaAttribs( (sal_uInt16)nPara );
+ const SvxULSpaceItem& rItem = (const SvxULSpaceItem&) rItems.Get( EE_PARA_ULSPACE );
+ nUpper = Max( nUpper, (long)rItem.GetUpper() );
+ }
+ if( nUpper == 0L )
+ rSet.DisableItem( SID_PARASPACE_DECREASE );
+ }
+ else
+ {
+ // Wird zur Zeit nie disabled !
+ //rSet.DisableItem( SID_PARASPACE_INCREASE );
+ //rSet.DisableItem( SID_PARASPACE_DECREASE );
+ }
+
+ // Absatzausrichtung
+ SvxAdjust eAdj = ( (const SvxAdjustItem&) aAttrSet.Get( EE_PARA_JUST ) ).GetAdjust();
+ switch( eAdj )
+ {
+ case SVX_ADJUST_LEFT:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_LEFT, sal_True ) );
+ break;
+ case SVX_ADJUST_CENTER:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_CENTER, sal_True ) );
+ break;
+ case SVX_ADJUST_RIGHT:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_RIGHT, sal_True ) );
+ break;
+ case SVX_ADJUST_BLOCK:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_ADJUST_BLOCK, sal_True ) );
+ break;
+ default:
+ break;
+ }
+
+ // paragraph text direction
+ if( bDisableParagraphTextDirection )
+ {
+ rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ }
+ else
+ {
+ switch( ( ( (SvxFrameDirectionItem&) aAttrSet.Get( EE_PARA_WRITINGDIR ) ) ).GetValue() )
+ {
+ case FRMDIR_VERT_TOP_LEFT:
+ case FRMDIR_VERT_TOP_RIGHT:
+ {
+ rSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT );
+ rSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT );
+ }
+ break;
+
+ case FRMDIR_HORI_LEFT_TOP:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, sal_True ) );
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, sal_False ) );
+ break;
+
+ case FRMDIR_HORI_RIGHT_TOP:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, sal_False ) );
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, sal_True ) );
+ break;
+
+ // #107865#
+ // The case for the superordinate object is missing.
+ case FRMDIR_ENVIRONMENT:
+ {
+ SdDrawDocument* pDoc = mpView->GetDoc();
+ ::com::sun::star::text::WritingMode eMode = pDoc->GetDefaultWritingMode();
+ sal_Bool bIsLeftToRight(sal_False);
+
+ if(::com::sun::star::text::WritingMode_LR_TB == eMode
+ || ::com::sun::star::text::WritingMode_TB_RL == eMode)
+ {
+ bIsLeftToRight = sal_True;
+ }
+
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, bIsLeftToRight ) );
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, !bIsLeftToRight ) );
+ }
+ break;
+ }
+ }
+
+/* #i35937#
+ if (aAttrSet.GetItemState(EE_PARA_BULLETSTATE) == SFX_ITEM_ON)
+ {
+ SfxUInt16Item aBulletState((const SfxUInt16Item&) aAttrSet.Get(EE_PARA_BULLETSTATE));
+
+ if (aBulletState.GetValue() != 0)
+ {
+ rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, sal_True));
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, sal_False));
+ }
+ }
+*/
+ sal_uInt16 nLineSpace = (sal_uInt16) ( (const SvxLineSpacingItem&) aAttrSet.
+ Get( EE_PARA_SBL ) ).GetPropLineSpace();
+ switch( nLineSpace )
+ {
+ case 100:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, sal_True ) );
+ break;
+ case 150:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, sal_True ) );
+ break;
+ case 200:
+ rSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, sal_True ) );
+ break;
+ }
+ }
+
+ // Ausrichtung (hoch/tief) wird auch im Gliederungsmodus gebraucht
+ SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
+ aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
+
+ if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
+ rSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, sal_True ) );
+ else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
+ rSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, sal_True ) );
+}
+
+/*************************************************************************
+|*
+|* Command event
+|*
+\************************************************************************/
+
+void TextObjectBar::Command( const CommandEvent& )
+{
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx
new file mode 100755
index 000000000000..9c2fc112cf3c
--- /dev/null
+++ b/sd/source/ui/view/drtxtob1.cxx
@@ -0,0 +1,612 @@
+/*************************************************************************
+ *
+ * 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 "TextObjectBar.hxx"
+
+
+#include <svx/svxids.hrc>
+
+#include <editeng/editview.hxx>
+#include <editeng/editeng.hxx>
+#include <editeng/unolingu.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/ulspitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/adjitem.hxx>
+#include <vcl/vclenum.hxx>
+#include <sfx2/app.hxx>
+#include <svl/whiter.hxx>
+#include <svl/itempool.hxx>
+#include <svl/style.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <editeng/escpitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/shdditem.hxx>
+#include <svx/xtable.hxx>
+#include <svx/svdobj.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/flstitem.hxx>
+#include <editeng/editeng.hxx>
+#include <svl/intitem.hxx>
+#include <editeng/scripttypeitem.hxx>
+#include <svx/svdoutl.hxx>
+#include <editeng/writingmodeitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svl/itemiter.hxx>
+
+
+#include "app.hrc"
+
+#include "eetext.hxx"
+#include "ViewShell.hxx"
+#include "drawview.hxx"
+#include "drawdoc.hxx"
+#include "OutlineView.hxx"
+#include "Window.hxx"
+#include "futempl.hxx"
+#include "DrawDocShell.hxx"
+#include "Outliner.hxx"
+#include "futext.hxx"
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Bearbeitung der SfxRequests
+|*
+\************************************************************************/
+
+void TextObjectBar::Execute( SfxRequest &rReq )
+{
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const SfxPoolItem* pPoolItem = NULL;
+ sal_uInt16 nSlot = rReq.GetSlot();
+ sal_Bool bOutlineMode = sal_False;
+ OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+
+ std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
+
+ if (mpView->ISA(OutlineView))
+ {
+ bOutlineMode = sal_True;
+ pOLV = static_cast<OutlineView*>(mpView)
+ ->GetViewByWindow(mpViewShell->GetActiveWindow());
+
+ aGuard.reset( new OutlineViewModelChangeGuard( static_cast<OutlineView&>(*mpView) ) );
+ }
+
+ switch (nSlot)
+ {
+ case SID_STYLE_APPLY:
+ {
+ if( pArgs )
+ {
+ SdDrawDocument* pDoc = mpView->GetDoc();
+ OSL_ASSERT (mpViewShell->GetViewShell()!=NULL);
+ FunctionReference xFunc( FuTemplate::Create( mpViewShell, static_cast< ::sd::Window*>( mpViewShell->GetViewShell()->GetWindow()), mpView, pDoc, rReq ) );
+
+ if(xFunc.is())
+ {
+ xFunc->Activate();
+ xFunc->Deactivate();
+
+ if( rReq.GetSlot() == SID_STYLE_APPLY )
+ {
+ if( mpViewShell && mpViewShell->GetViewFrame() )
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY );
+ }
+ }
+ }
+ else
+ {
+ if( mpViewShell && mpViewShell->GetViewFrame() )
+ mpViewShell->GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON );
+ }
+
+ rReq.Done();
+ }
+ break;
+
+ case SID_PARASPACE_INCREASE:
+ case SID_PARASPACE_DECREASE:
+ {
+ if( pOLV )
+ {
+ ESelection aSel = pOLV->GetSelection();
+ aSel.Adjust();
+ sal_uLong nStartPara = aSel.nStartPara;
+ sal_uLong nEndPara = aSel.nEndPara;
+ if( !aSel.HasRange() )
+ {
+ nStartPara = 0;
+ nEndPara = pOLV->GetOutliner()->GetParagraphCount() - 1;
+ }
+ for( sal_uLong nPara = nStartPara; nPara <= nEndPara; nPara++ )
+ {
+ SfxStyleSheet* pStyleSheet = NULL;
+ if (pOLV->GetOutliner() != NULL)
+ pStyleSheet = pOLV->GetOutliner()->GetStyleSheet(nPara);
+ if (pStyleSheet != NULL)
+ {
+ SfxItemSet aAttr( pStyleSheet->GetItemSet() );
+ SfxItemSet aTmpSet( pOLV->GetOutliner()->GetParaAttribs( (sal_uInt16) nPara ) );
+ aAttr.Put( aTmpSet, sal_False ); // sal_False= InvalidItems nicht als Default, sondern als "Loecher" betrachten
+ const SvxULSpaceItem& rItem = (const SvxULSpaceItem&) aAttr.Get( EE_PARA_ULSPACE );
+ SvxULSpaceItem* pNewItem = (SvxULSpaceItem*) rItem.Clone();
+
+ long nUpper = pNewItem->GetUpper();
+ if( nSlot == SID_PARASPACE_INCREASE )
+ nUpper += 100;
+ else
+ {
+ nUpper -= 100;
+ nUpper = Max( (long) nUpper, 0L );
+ }
+ pNewItem->SetUpper( (sal_uInt16) nUpper );
+
+ long nLower = pNewItem->GetLower();
+ if( nSlot == SID_PARASPACE_INCREASE )
+ nLower += 100;
+ else
+ {
+ nLower -= 100;
+ nLower = Max( (long) nLower, 0L );
+ }
+ pNewItem->SetLower( (sal_uInt16) nLower );
+
+ SfxItemSet aNewAttrs( aAttr );
+ aNewAttrs.Put( *pNewItem );
+ delete pNewItem;
+ pOLV->GetOutliner()->SetParaAttribs( (sal_uInt16)nPara, aNewAttrs );
+ }
+ }
+ }
+ else
+ {
+ // Der folgende Code kann enabled werden, wenn ich von
+ // JOE einen richtigen Status (DontCare) bekomme;
+
+ // Wird enabled, obwohl es nicht richtig funktioniert (s.o.)
+ SfxItemSet aEditAttr( mpView->GetDoc()->GetPool() );
+ mpView->GetAttributes( aEditAttr );
+ if( aEditAttr.GetItemState( EE_PARA_ULSPACE ) >= SFX_ITEM_AVAILABLE )
+ {
+ SfxItemSet aNewAttrs(*(aEditAttr.GetPool()), aEditAttr.GetRanges());
+ const SvxULSpaceItem& rItem = (const SvxULSpaceItem&) aEditAttr.Get( EE_PARA_ULSPACE );
+ SvxULSpaceItem* pNewItem = (SvxULSpaceItem*) rItem.Clone();
+ long nUpper = pNewItem->GetUpper();
+
+ if( nSlot == SID_PARASPACE_INCREASE )
+ nUpper += 100;
+ else
+ {
+ nUpper -= 100;
+ nUpper = Max( (long) nUpper, 0L );
+ }
+ pNewItem->SetUpper( (sal_uInt16) nUpper );
+
+ long nLower = pNewItem->GetLower();
+ if( nSlot == SID_PARASPACE_INCREASE )
+ nLower += 100;
+ else
+ {
+ nLower -= 100;
+ nLower = Max( (long) nLower, 0L );
+ }
+ pNewItem->SetLower( (sal_uInt16) nLower );
+
+ aNewAttrs.Put( *pNewItem );
+ delete pNewItem;
+
+ mpView->SetAttributes( aNewAttrs );
+ }
+ }
+ rReq.Done();
+
+ Invalidate();
+ // Um die Preview (im Gliederungsmodus) zu aktualisieren muss
+ // der Slot invalidiert werden:
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, sal_True, sal_False );
+ }
+ break;
+
+ case SID_OUTLINE_LEFT:
+ {
+ if (pOLV)
+ {
+ pOLV->AdjustDepth( -1 );
+
+ // Ensure bold/italic etc. icon state updates
+ Invalidate();
+ // #96551# trigger preview refresh
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, sal_True, sal_False );
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_RIGHT:
+ {
+ if (pOLV)
+ {
+ pOLV->AdjustDepth( 1 );
+
+ // Ensure bold/italic etc. icon state updates
+ Invalidate();
+ // #96551# trigger preview refresh
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, sal_True, sal_False );
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_UP:
+ {
+ if (pOLV)
+ {
+ pOLV->AdjustHeight( -1 );
+
+ // #96551# trigger preview refresh
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, sal_True, sal_False );
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_DOWN:
+ {
+ if (pOLV)
+ {
+ pOLV->AdjustHeight( 1 );
+
+ // #96551# trigger preview refresh
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, sal_True, sal_False );
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_TEXTDIRECTION_LEFT_TO_RIGHT:
+ case SID_TEXTDIRECTION_TOP_TO_BOTTOM:
+ {
+ mpView->SdrEndTextEdit();
+ SfxItemSet aAttr( mpView->GetDoc()->GetPool(), SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 0 );
+ aAttr.Put( SvxWritingModeItem(
+ nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ?
+ com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL,
+ SDRATTR_TEXTDIRECTION ) );
+ rReq.Done( aAttr );
+ mpView->SetAttributes( aAttr );
+ Invalidate();
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, sal_True, sal_False );
+ }
+ break;
+
+ case FN_NUM_BULLET_ON:
+ if( pOLV )
+ pOLV->ToggleBullets();
+ break;
+
+ case SID_GROW_FONT_SIZE:
+ case SID_SHRINK_FONT_SIZE:
+ {
+ const SvxFontListItem* pFonts = (const SvxFontListItem*)mpViewShell->GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST );
+ const FontList* pFontList = pFonts ? pFonts->GetFontList(): 0;
+ if( pFontList )
+ {
+ FuText::ChangeFontSize( nSlot == SID_GROW_FONT_SIZE, pOLV, pFontList, mpView );
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_THES:
+ {
+ String aReplaceText;
+ SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False );
+ if (pItem2)
+ aReplaceText = pItem2->GetValue();
+ if (aReplaceText.Len() > 0)
+ ReplaceTextWithSynonym( pOLV->GetEditView(), aReplaceText );
+ }
+ break;
+
+ default:
+ {
+ SfxItemSet aEditAttr( mpView->GetDoc()->GetPool() );
+ mpView->GetAttributes( aEditAttr );
+ SfxItemSet aNewAttr(*(aEditAttr.GetPool()), aEditAttr.GetRanges());
+
+ if( !pArgs )
+ {
+ //aNewAttr.InvalidateAllItems(); <- Macht Probleme (#35465#)
+
+ switch ( nSlot )
+ {
+ case SID_ATTR_CHAR_WEIGHT:
+ {
+ FontWeight eFW = ( (const SvxWeightItem&) aEditAttr.
+ Get( EE_CHAR_WEIGHT ) ).GetWeight();
+ aNewAttr.Put( SvxWeightItem( eFW == WEIGHT_NORMAL ?
+ WEIGHT_BOLD : WEIGHT_NORMAL,
+ EE_CHAR_WEIGHT ) );
+ }
+ break;
+ case SID_ATTR_CHAR_POSTURE:
+ {
+ FontItalic eFI = ( (const SvxPostureItem&) aEditAttr.
+ Get( EE_CHAR_ITALIC ) ).GetPosture();
+ aNewAttr.Put( SvxPostureItem( eFI == ITALIC_NORMAL ?
+ ITALIC_NONE : ITALIC_NORMAL,
+ EE_CHAR_ITALIC ) );
+ }
+ break;
+ case SID_ATTR_CHAR_UNDERLINE:
+ {
+ FontUnderline eFU = ( (const SvxUnderlineItem&) aEditAttr.
+ Get( EE_CHAR_UNDERLINE ) ).GetLineStyle();
+ aNewAttr.Put( SvxUnderlineItem( eFU == UNDERLINE_SINGLE ?
+ UNDERLINE_NONE : UNDERLINE_SINGLE,
+ EE_CHAR_UNDERLINE ) );
+ }
+ break;
+ case SID_ATTR_CHAR_OVERLINE:
+ {
+ FontUnderline eFO = ( (const SvxOverlineItem&) aEditAttr.
+ Get( EE_CHAR_OVERLINE ) ).GetLineStyle();
+ aNewAttr.Put( SvxOverlineItem( eFO == UNDERLINE_SINGLE ?
+ UNDERLINE_NONE : UNDERLINE_SINGLE,
+ EE_CHAR_OVERLINE ) );
+ }
+ break;
+ case SID_ATTR_CHAR_CONTOUR:
+ {
+ aNewAttr.Put( SvxContourItem( !( (const SvxContourItem&) aEditAttr.
+ Get( EE_CHAR_OUTLINE ) ).GetValue(), EE_CHAR_OUTLINE ) );
+ }
+ break;
+ case SID_ATTR_CHAR_SHADOWED:
+ {
+ aNewAttr.Put( SvxShadowedItem( !( (const SvxShadowedItem&) aEditAttr.
+ Get( EE_CHAR_SHADOW ) ).GetValue(), EE_CHAR_SHADOW ) );
+ }
+ break;
+ case SID_ATTR_CHAR_STRIKEOUT:
+ {
+ FontStrikeout eFSO = ( ( (const SvxCrossedOutItem&) aEditAttr.
+ Get( EE_CHAR_STRIKEOUT ) ).GetStrikeout() );
+ aNewAttr.Put( SvxCrossedOutItem( eFSO == STRIKEOUT_SINGLE ?
+ STRIKEOUT_NONE : STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT ) );
+ }
+ break;
+
+ case SID_ATTR_PARA_ADJUST_LEFT:
+ {
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
+ }
+ break;
+ case SID_ATTR_PARA_ADJUST_CENTER:
+ {
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) );
+ }
+ break;
+ case SID_ATTR_PARA_ADJUST_RIGHT:
+ {
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+ }
+ break;
+ case SID_ATTR_PARA_ADJUST_BLOCK:
+ {
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) );
+ }
+ break;
+ case SID_ATTR_PARA_LINESPACE_10:
+ {
+ SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL );
+ aItem.SetPropLineSpace( 100 );
+ aNewAttr.Put( aItem );
+ }
+ break;
+ case SID_ATTR_PARA_LINESPACE_15:
+ {
+ SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL );
+ aItem.SetPropLineSpace( 150 );
+ aNewAttr.Put( aItem );
+ }
+ break;
+ case SID_ATTR_PARA_LINESPACE_20:
+ {
+ SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL );
+ aItem.SetPropLineSpace( 200 );
+ aNewAttr.Put( aItem );
+ }
+ break;
+ case SID_SET_SUPER_SCRIPT:
+ {
+ SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
+ SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
+ aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
+
+ if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT )
+ aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
+ else
+ aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
+ aNewAttr.Put( aItem );
+ }
+ break;
+ case SID_SET_SUB_SCRIPT:
+ {
+ SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
+ SvxEscapement eEsc = (SvxEscapement ) ( (const SvxEscapementItem&)
+ aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue();
+
+ if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT )
+ aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
+ else
+ aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
+ aNewAttr.Put( aItem );
+ }
+ break;
+
+ // Attribute fuer die TextObjectBar
+ case SID_ATTR_CHAR_FONT:
+ {
+ if( pArgs )
+ {
+ if( SFX_ITEM_SET == pArgs->GetItemState( EE_CHAR_FONTINFO, sal_True, &pPoolItem ) )
+ aNewAttr.Put( *pPoolItem );
+ }
+ else
+ mpViewShell->GetViewFrame()->GetDispatcher()->
+ Execute( SID_CHAR_DLG, SFX_CALLMODE_ASYNCHRON );
+ }
+ break;
+ case SID_ATTR_CHAR_FONTHEIGHT:
+ {
+ if( pArgs )
+ {
+ if( SFX_ITEM_SET == pArgs->GetItemState( EE_CHAR_FONTHEIGHT, sal_True, &pPoolItem ) )
+ aNewAttr.Put( *pPoolItem );
+ }
+ else
+ mpViewShell->GetViewFrame()->GetDispatcher()->
+ Execute( SID_CHAR_DLG, SFX_CALLMODE_ASYNCHRON );
+ }
+ break;
+ case SID_ATTR_CHAR_COLOR:
+ {
+ if( pArgs && SFX_ITEM_SET == pArgs->GetItemState( EE_CHAR_COLOR, sal_True, &pPoolItem ) )
+ aNewAttr.Put( *pPoolItem );
+ }
+ break;
+/* #i35937#
+ case FN_NUM_BULLET_ON:
+ {
+ if (aEditAttr.GetItemState(EE_PARA_BULLETSTATE) == SFX_ITEM_ON)
+ {
+ SfxUInt16Item aBulletState((const SfxUInt16Item&) aEditAttr.Get(EE_PARA_BULLETSTATE));
+
+ if (aBulletState.GetValue() != 0)
+ {
+ // Ausschalten
+ aNewAttr.Put(SfxUInt16Item(EE_PARA_BULLETSTATE, 0));
+ }
+ else
+ {
+ // Einschalten
+ aNewAttr.Put(SfxUInt16Item(EE_PARA_BULLETSTATE, 1));
+ }
+ }
+ else
+ {
+ // Einschalten
+ aNewAttr.Put(SfxUInt16Item(EE_PARA_BULLETSTATE, 1));
+ }
+ }
+ break;
+*/
+ }
+
+ rReq.Done( aNewAttr );
+ pArgs = rReq.GetArgs();
+ }
+ else if ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ||
+ nSlot == SID_ATTR_PARA_RIGHT_TO_LEFT )
+ {
+ sal_Bool bLeftToRight = nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT;
+
+ sal_uInt16 nAdjust = SVX_ADJUST_LEFT;
+ if( SFX_ITEM_ON == aEditAttr.GetItemState(EE_PARA_JUST, sal_True, &pPoolItem ) )
+ nAdjust = ( (SvxAdjustItem*)pPoolItem)->GetEnumValue();
+
+ if( bLeftToRight )
+ {
+ aNewAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_LEFT_TOP, EE_PARA_WRITINGDIR ) );
+ if( nAdjust == SVX_ADJUST_RIGHT )
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) );
+ }
+ else
+ {
+ aNewAttr.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) );
+ if( nAdjust == SVX_ADJUST_LEFT )
+ aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
+ }
+
+ rReq.Done( aNewAttr );
+ pArgs = rReq.GetArgs();
+
+ Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
+ }
+ else if ( nSlot == SID_ATTR_CHAR_FONT ||
+ nSlot == SID_ATTR_CHAR_FONTHEIGHT ||
+ nSlot == SID_ATTR_CHAR_POSTURE ||
+ nSlot == SID_ATTR_CHAR_WEIGHT )
+ {
+ // #i78017 establish the same behaviour as in Writer
+ sal_uInt16 nScriptType = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX;
+ if (nSlot == SID_ATTR_CHAR_FONT)
+ nScriptType = mpView->GetScriptType();
+
+ SfxItemPool& rPool = mpView->GetDoc()->GetPool();
+ SvxScriptSetItem aSvxScriptSetItem( nSlot, rPool );
+ aSvxScriptSetItem.PutItemForScriptType( nScriptType, pArgs->Get( rPool.GetWhich( nSlot ) ) );
+ aNewAttr.Put( aSvxScriptSetItem.GetItemSet() );
+ rReq.Done( aNewAttr );
+ pArgs = rReq.GetArgs();
+ }
+
+ mpView->SetAttributes(*pArgs);
+
+ // Aus Performance- und Erweiterungsgruenden wird
+ // jetzt die komplette Shell invalidiert
+ Invalidate();
+
+ // Um die Preview (im Gliederungsmodus) zu aktualisieren muss
+ // der Slot invalidiert werden:
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_PREVIEW_STATE, sal_True, sal_False );
+ }
+ break;
+ }
+
+ Invalidate( SID_OUTLINE_LEFT );
+ Invalidate( SID_OUTLINE_RIGHT );
+ Invalidate( SID_OUTLINE_UP );
+ Invalidate( SID_OUTLINE_DOWN );
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
new file mode 100755
index 000000000000..9a289a6d4927
--- /dev/null
+++ b/sd/source/ui/view/drviews1.cxx
@@ -0,0 +1,1449 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include "ViewShellImplementation.hxx"
+
+#include "DrawController.hxx"
+#include <com/sun/star/embed/EmbedStates.hpp>
+
+#include "comphelper/anytostring.hxx"
+#include "comphelper/scopeguard.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "rtl/ref.hxx"
+
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svx/svdpagv.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <svx/svdoole2.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/scrbar.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdopage.hxx>
+#include <vcl/msgbox.hxx>
+#include <sot/storage.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/globl3d.hxx>
+#include <svx/fmglob.hxx>
+#include <editeng/outliner.hxx>
+
+
+#include "misc.hxx"
+
+#ifdef STARIMAGE_AVAILABLE
+#ifndef _SIMDLL_HXX
+#include <sim2/simdll.hxx>
+#endif
+#endif
+
+#include <svx/dialogs.hrc>
+
+#include "view/viewoverlaymanager.hxx"
+
+#include "glob.hrc"
+#include "app.hrc"
+#include "res_bmp.hrc"
+#include "strings.hrc"
+#include "helpids.h"
+
+#include "app.hxx"
+#include "fupoor.hxx"
+#include "sdresid.hxx"
+#include "fusel.hxx"
+#include "sdpage.hxx"
+#include "FrameView.hxx"
+#include "stlpool.hxx"
+#include "Window.hxx"
+#ifndef SD_DRAWVIEW_HXX
+#include "drawview.hxx"
+#endif
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "Ruler.hxx"
+#include "Client.hxx"
+#include "slideshow.hxx"
+#include "optsitem.hxx"
+#include "fusearch.hxx"
+#include "Outliner.hxx"
+#include "AnimationChildWindow.hxx"
+#include "SdUnoDrawView.hxx"
+#include "ToolBarManager.hxx"
+#include "FormShellManager.hxx"
+#include "ViewShellBase.hxx"
+#include "LayerDialogChildWindow.hxx"
+#include "LayerTabBar.hxx"
+#include "ViewShellManager.hxx"
+#include "ViewShellHint.hxx"
+
+#include <sfx2/request.hxx>
+#include <boost/bind.hpp>
+
+#ifdef _MSC_VER
+#if (_MSC_VER < 1400)
+#pragma optimize ( "", off )
+#endif
+#endif
+
+using namespace com::sun::star;
+
+namespace sd {
+
+void DrawViewShell::Activate(sal_Bool bIsMDIActivate)
+{
+ ViewShell::Activate(bIsMDIActivate);
+}
+
+void DrawViewShell::UIActivating( SfxInPlaceClient* pCli )
+{
+ ViewShell::UIActivating(pCli);
+
+ // #94252# Disable own controls
+ maTabControl.Disable();
+ if (GetLayerTabControl() != NULL)
+ GetLayerTabControl()->Disable();
+}
+
+void DrawViewShell::UIDeactivated( SfxInPlaceClient* pCli )
+{
+ // #94252# Enable own controls
+ maTabControl.Enable();
+ if (GetLayerTabControl() != NULL)
+ GetLayerTabControl()->Enable();
+
+ ViewShell::UIDeactivated(pCli);
+}
+
+
+/*************************************************************************
+|*
+|* Deactivate()
+|*
+\************************************************************************/
+
+void DrawViewShell::Deactivate(sal_Bool bIsMDIActivate)
+{
+ ViewShell::Deactivate(bIsMDIActivate);
+}
+
+namespace
+{
+ class LockUI
+ {
+ private:
+ void Lock(bool bLock);
+ SfxViewFrame *mpFrame;
+ public:
+ LockUI(SfxViewFrame *pFrame) : mpFrame(pFrame) { Lock(true); }
+ ~LockUI() { Lock(false); }
+
+ };
+
+ void LockUI::Lock(bool bLock)
+ {
+ if (!mpFrame)
+ return;
+ mpFrame->Enable( !bLock );
+ }
+}
+
+/*************************************************************************
+|*
+|* Wird gerufen, wenn sich der Selektionszustand der View aendert
+|*
+\************************************************************************/
+void DrawViewShell::SelectionHasChanged (void)
+{
+ Invalidate();
+
+ //Update3DWindow(); // 3D-Controller
+ SfxBoolItem aItem( SID_3D_STATE, sal_True );
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_3D_STATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+
+ SdrOle2Obj* pOleObj = NULL;
+ SdrGrafObj* pGrafObj = NULL;
+
+ if ( mpDrawView->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ sal_uInt32 nInv = pObj->GetObjInventor();
+ sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
+
+ if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
+ {
+ pOleObj = (SdrOle2Obj*) pObj;
+ UpdateIMapDlg( pObj );
+ }
+ else if (nSdrObjKind == OBJ_GRAF)
+ {
+ pGrafObj = (SdrGrafObj*) pObj;
+ UpdateIMapDlg( pObj );
+ }
+ }
+ }
+
+ ViewShellBase& rBase = GetViewShellBase();
+ rBase.SetVerbs( uno::Sequence< embed::VerbDescriptor >() );
+
+ try
+ {
+ Client* pIPClient = static_cast<Client*>(rBase.GetIPClient());
+ if ( pIPClient && pIPClient->IsObjectInPlaceActive() )
+ {
+ /**********************************************************************
+ * Ggf. OLE-Objekt beruecksichtigen und deaktivieren
+ **********************************************************************/
+
+ // this means we recently deselected an inplace active ole object so
+ // we need to deselect it now
+ if (!pOleObj)
+ {
+ //#i47279# disable frame until after object has completed unload
+ LockUI aUILock(GetViewFrame());
+ pIPClient->DeactivateObject();
+ //HMHmpDrView->ShowMarkHdl();
+ }
+ else
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
+ if ( xObj.is() )
+ {
+ rBase.SetVerbs( xObj->getSupportedVerbs() );
+ }
+ else
+ {
+ rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
+ }
+ }
+ }
+ else
+ {
+ if ( pOleObj )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj = pOleObj->GetObjRef();
+ if ( xObj.is() )
+ {
+ rBase.SetVerbs( xObj->getSupportedVerbs() );
+ }
+ else
+ {
+ rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
+ }
+ }
+ else
+ {
+ rBase.SetVerbs( uno::Sequence < embed::VerbDescriptor >() );
+ }
+ }
+ }
+ catch( ::com::sun::star::uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR(
+ (rtl::OString("sd::DrawViewShell::SelectionHasChanged(), "
+ "exception caught: ") +
+ rtl::OUStringToOString(
+ comphelper::anyToString( cppu::getCaughtException() ),
+ RTL_TEXTENCODING_UTF8 )).getStr() );
+ }
+
+ if( HasCurrentFunction() )
+ {
+ GetCurrentFunction()->SelectionHasChanged();
+ }
+ else
+ {
+ GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView);
+ }
+
+ // #96124# Invalidate for every subshell
+ GetViewShellBase().GetViewShellManager()->InvalidateAllSubShells(this);
+
+ mpDrawView->UpdateSelectionClipboard( sal_False );
+
+ GetViewShellBase().GetDrawController().FireSelectionChangeListener();
+}
+
+
+/*************************************************************************
+|*
+|* Zoomfaktor setzen
+|*
+\************************************************************************/
+
+void DrawViewShell::SetZoom( long nZoom )
+{
+ // Make sure that the zoom factor will not be recalculated on
+ // following window resizings.
+ mbZoomOnPage = sal_False;
+ ViewShell::SetZoom( nZoom );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
+ mpViewOverlayManager->onZoomChanged();
+}
+
+/*************************************************************************
+|*
+|* Zoomrechteck fuer aktives Fenster einstellen
+|*
+\************************************************************************/
+
+void DrawViewShell::SetZoomRect( const Rectangle& rZoomRect )
+{
+ ViewShell::SetZoomRect( rZoomRect );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
+ mpViewOverlayManager->onZoomChanged();
+}
+
+/*************************************************************************
+|*
+|* PrepareClose, ggfs. Texteingabe beenden, damit andere Viewshells ein
+|* aktualisiertes Textobjekt vorfinden
+|*
+\************************************************************************/
+
+sal_uInt16 DrawViewShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
+{
+ if ( ViewShell::PrepareClose(bUI, bForBrowsing) != sal_True )
+ return sal_False;
+
+ sal_Bool bRet = sal_True;
+
+ if( bRet && HasCurrentFunction() )
+ {
+ sal_uInt16 nID = GetCurrentFunction()->GetSlotID();
+ if (nID == SID_TEXTEDIT || nID == SID_ATTR_CHAR)
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+ }
+ else if( !bRet )
+ {
+ maCloseTimer.SetTimeoutHdl( LINK( this, DrawViewShell, CloseHdl ) );
+ maCloseTimer.SetTimeout( 20 );
+ maCloseTimer.Start();
+ }
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|* Status (Enabled/Disabled) von Menue-SfxSlots setzen
+|*
+\************************************************************************/
+
+void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive)
+{
+ if (meEditMode != eEMode || mbIsLayerModeActive != bIsLayerModeActive)
+ {
+ ViewShellManager::UpdateLock aLock (GetViewShellBase().GetViewShellManager());
+
+ sal_uInt16 nActualPageNum = 0;
+
+ GetViewShellBase().GetDrawController().FireChangeEditMode (eEMode == EM_MASTERPAGE);
+ GetViewShellBase().GetDrawController().FireChangeLayerMode (bIsLayerModeActive);
+
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ LayerTabBar* pLayerBar = GetLayerTabControl();
+ if (pLayerBar != NULL)
+ pLayerBar->EndEditMode();
+ maTabControl.EndEditMode();
+
+ if (mePageKind == PK_HANDOUT)
+ {
+ // Bei Handzetteln nur MasterPage zulassen
+ eEMode = EM_MASTERPAGE;
+ }
+
+ meEditMode = eEMode;
+ mbIsLayerModeActive = bIsLayerModeActive;
+
+ // Determine whether to show the master view toolbar. The master
+ // page mode has to be active and the shell must not be a handout
+ // view.
+ bool bShowMasterViewToolbar (meEditMode == EM_MASTERPAGE
+ && GetShellType() != ViewShell::ST_HANDOUT);
+
+ // If the master view toolbar is not shown we hide it before
+ // switching the edit mode.
+ if (::sd::ViewShell::mpImpl->mbIsInitialized
+ && IsMainViewShell()
+ && ! bShowMasterViewToolbar)
+ {
+ GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::TBG_MASTER_MODE);
+ }
+
+ if (meEditMode == EM_PAGE)
+ {
+ /******************************************************************
+ * PAGEMODE
+ ******************************************************************/
+
+ maTabControl.Clear();
+
+ SdPage* pPage;
+ String aPageName;
+ sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
+
+ for (sal_uInt16 i = 0; i < nPageCnt; i++)
+ {
+ pPage = GetDoc()->GetSdPage(i, mePageKind);
+ aPageName = pPage->GetName();
+ maTabControl.InsertPage(i + 1, aPageName);
+
+ if ( pPage->IsSelected() && nActualPageNum == 0 )
+ {
+ nActualPageNum = i;
+ }
+ }
+
+ maTabControl.SetCurPageId(nActualPageNum + 1);
+
+ SwitchPage(nActualPageNum);
+ }
+ else
+ {
+ /******************************************************************
+ * MASTERPAGE
+ ******************************************************************/
+ GetViewFrame()->SetChildWindow(
+ AnimationChildWindow::GetChildWindowId(), sal_False );
+
+ if (!mpActualPage)
+ {
+ // Sofern es keine mpActualPage gibt, wird die erste genommen
+ mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
+ }
+
+ maTabControl.Clear();
+ sal_uInt16 nActualMasterPageNum = 0;
+ sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
+
+ for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
+ {
+ SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
+ String aLayoutName(pMaster->GetLayoutName());
+ aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
+
+ maTabControl.InsertPage(i + 1, aLayoutName);
+
+ if (&(mpActualPage->TRG_GetMasterPage()) == pMaster)
+ {
+ nActualMasterPageNum = i;
+ }
+ }
+
+ maTabControl.SetCurPageId(nActualMasterPageNum + 1);
+ SwitchPage(nActualMasterPageNum);
+ }
+
+ // If the master view toolbar is to be shown we turn it on after the
+ // edit mode has been changed.
+ if (::sd::ViewShell::mpImpl->mbIsInitialized
+ && IsMainViewShell()
+ && bShowMasterViewToolbar)
+ {
+ GetViewShellBase().GetToolBarManager()->SetToolBar(
+ ToolBarManager::TBG_MASTER_MODE,
+ ToolBarManager::msMasterViewToolBar);
+ }
+
+ if ( ! mbIsLayerModeActive)
+ {
+ maTabControl.Show();
+ // Set the tab control only for draw pages. For master page
+ // this has been done already above.
+ if (meEditMode == EM_PAGE)
+ maTabControl.SetCurPageId (nActualPageNum + 1);
+ }
+ /*AF: The LayerDialogChildWindow is not used anymore (I hope).
+ if (GetViewFrame()->KnowsChildWindow(
+ LayerDialogChildWindow::GetChildWindowId()))
+ {
+ GetViewFrame()->SetChildWindow(
+ LayerDialogChildWindow::GetChildWindowId(),
+ IsLayerModeActive());
+ }
+ */
+ ResetActualLayer();
+
+ Invalidate( SID_PAGEMODE );
+ Invalidate( SID_LAYERMODE );
+ Invalidate( SID_MASTERPAGE );
+ Invalidate( SID_DELETE_MASTER_PAGE );
+ Invalidate( SID_DELETE_PAGE );
+ Invalidate( SID_SLIDE_MASTERPAGE );
+ Invalidate( SID_TITLE_MASTERPAGE );
+ Invalidate( SID_NOTES_MASTERPAGE );
+ Invalidate( SID_HANDOUT_MASTERPAGE );
+ }
+}
+
+
+
+
+bool DrawViewShell::IsLayerModeActive (void) const
+{
+ return mbIsLayerModeActive;
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Groesse des TabControls und der ModeButtons zurueckgeben
+|*
+\************************************************************************/
+
+long DrawViewShell::GetHCtrlWidth()
+{
+ // return maTabControl.GetSizePixel().Width();
+ return 0;
+}
+
+
+/*************************************************************************
+|*
+|* Horizontales Lineal erzeugen
+|*
+\************************************************************************/
+
+SvxRuler* DrawViewShell::CreateHRuler (::sd::Window* pWin, sal_Bool bIsFirst)
+{
+ Ruler* pRuler;
+ WinBits aWBits;
+ sal_uInt16 nFlags = SVXRULER_SUPPORT_OBJECT;
+
+ if ( bIsFirst )
+ {
+ aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER | WB_EXTRAFIELD;
+ nFlags |= ( SVXRULER_SUPPORT_SET_NULLOFFSET |
+ SVXRULER_SUPPORT_TABS |
+ SVXRULER_SUPPORT_PARAGRAPH_MARGINS ); // Neu
+ }
+ else
+ aWBits = WB_HSCROLL | WB_3DLOOK | WB_BORDER;
+
+ pRuler = new Ruler (*this, GetParentWindow(), pWin, nFlags,
+ GetViewFrame()->GetBindings(), aWBits);
+ pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
+
+ // Metric ...
+ sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
+
+ if( nMetric == 0xffff )
+ nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
+
+ pRuler->SetUnit( FieldUnit( nMetric ) );
+
+ // ... und auch DefTab am Lineal einstellen
+ pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // Neu
+
+ Fraction aUIScale(pWin->GetMapMode().GetScaleX());
+ aUIScale *= GetDoc()->GetUIScale();
+ pRuler->SetZoom(aUIScale);
+
+ return pRuler;
+}
+
+/*************************************************************************
+|*
+|* Vertikales Lineal erzeugen
+|*
+\************************************************************************/
+
+SvxRuler* DrawViewShell::CreateVRuler(::sd::Window* pWin)
+{
+ Ruler* pRuler;
+ WinBits aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER;
+ sal_uInt16 nFlags = SVXRULER_SUPPORT_OBJECT;
+
+ pRuler = new Ruler(*this, GetParentWindow(), pWin, nFlags,
+ GetViewFrame()->GetBindings(), aWBits);
+ pRuler->SetSourceUnit(pWin->GetMapMode().GetMapUnit());
+
+ // #96629# Metric same as HRuler, use document setting
+ sal_uInt16 nMetric = (sal_uInt16)GetDoc()->GetUIUnit();
+
+ if( nMetric == 0xffff )
+ nMetric = (sal_uInt16)GetViewShellBase().GetViewFrame()->GetDispatcher()->GetModule()->GetFieldUnit();
+
+ pRuler->SetUnit( FieldUnit( nMetric ) );
+
+ Fraction aUIScale(pWin->GetMapMode().GetScaleY());
+ aUIScale *= GetDoc()->GetUIScale();
+ pRuler->SetZoom(aUIScale);
+
+ return pRuler;
+}
+
+/*************************************************************************
+|*
+|* Horizontales Lineal aktualisieren
+|*
+\************************************************************************/
+
+void DrawViewShell::UpdateHRuler()
+{
+ Invalidate( SID_ATTR_LONG_LRSPACE );
+ Invalidate( SID_RULER_PAGE_POS );
+ Invalidate( SID_RULER_OBJECT );
+ Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
+
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->ForceUpdate();
+}
+
+/*************************************************************************
+|*
+|* Vertikales Lineal aktualisieren
+|*
+\************************************************************************/
+
+void DrawViewShell::UpdateVRuler()
+{
+ Invalidate( SID_ATTR_LONG_LRSPACE );
+ Invalidate( SID_RULER_PAGE_POS );
+ Invalidate( SID_RULER_OBJECT );
+
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->ForceUpdate();
+}
+
+/*************************************************************************
+|*
+|* Metrik setzen
+|*
+\************************************************************************/
+
+void DrawViewShell::SetUIUnit(FieldUnit eUnit)
+{
+ ViewShell::SetUIUnit(eUnit);
+}
+
+/*************************************************************************
+|*
+|* TabControl nach Splitteraenderung aktualisieren
+|*
+\************************************************************************/
+
+IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab )
+{
+ const long int nMax = maViewSize.Width() - maScrBarWH.Width()
+ - maTabControl.GetPosPixel().X() ;
+
+ Size aTabSize = maTabControl.GetSizePixel();
+ aTabSize.Width() = Min(pTab->GetSplitSize(), (long)(nMax-1));
+
+ maTabControl.SetSizePixel(aTabSize);
+ GetLayerTabControl()->SetSizePixel(aTabSize);
+
+ Point aPos = maTabControl.GetPosPixel();
+ aPos.X() += aTabSize.Width();
+
+ Size aScrSize(nMax - aTabSize.Width(), maScrBarWH.Height());
+ mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
+
+ return 0;
+}
+
+/// inherited from sd::ViewShell
+SdPage* DrawViewShell::getCurrentPage() const
+{
+ const sal_Int32 nPageCount = (meEditMode == EM_PAGE)?
+ GetDoc()->GetSdPageCount(mePageKind):
+ GetDoc()->GetMasterSdPageCount(mePageKind);
+
+ sal_Int32 nCurrentPage = maTabControl.GetCurPageId() - 1;
+ DBG_ASSERT( (nPageCount>0) && (nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!" );
+ if( (nPageCount < 0) || (nCurrentPage>=nPageCount) )
+ nCurrentPage = 0; // play safe here
+
+ if (meEditMode == EM_PAGE)
+ {
+ return GetDoc()->GetSdPage((sal_uInt16)nCurrentPage, mePageKind);
+ }
+ else // EM_MASTERPAGE
+ {
+ return GetDoc()->GetMasterSdPage((sal_uInt16)nCurrentPage, mePageKind);
+ }
+}
+
+/*************************************************************************
+|*
+|* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
+|* hat (z. B. durch Undo)
+|*
+\************************************************************************/
+
+void DrawViewShell::ResetActualPage()
+{
+ sal_uInt16 nCurrentPage = maTabControl.GetCurPageId() - 1;
+ sal_uInt16 nPageCount = (meEditMode == EM_PAGE)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
+ if (nPageCount > 0)
+ nCurrentPage = Min((sal_uInt16)(nPageCount - 1), nCurrentPage);
+ else
+ nCurrentPage = 0;
+
+ if (meEditMode == EM_PAGE)
+ {
+
+ // Update fuer TabControl
+ maTabControl.Clear();
+
+ SdPage* pPage = NULL;
+ String aPageName;
+
+ for (sal_uInt16 i = 0; i < nPageCount; i++)
+ {
+ pPage = GetDoc()->GetSdPage(i, mePageKind);
+ aPageName = pPage->GetName();
+ maTabControl.InsertPage(i + 1, aPageName);
+
+ // Selektionskennungen der Seiten korrigieren
+ GetDoc()->SetSelected(pPage, i == nCurrentPage);
+ }
+
+ maTabControl.SetCurPageId(nCurrentPage + 1);
+ }
+ else // EM_MASTERPAGE
+ {
+ SdPage* pActualPage = GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind);
+ maTabControl.Clear();
+ sal_uInt16 nActualMasterPageNum = 0;
+
+ sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
+ for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
+ {
+ SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
+ String aLayoutName(pMaster->GetLayoutName());
+ aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
+ maTabControl.InsertPage(i + 1, aLayoutName);
+
+ if (pActualPage == pMaster)
+ nActualMasterPageNum = i;
+ }
+
+ maTabControl.SetCurPageId(nActualMasterPageNum + 1);
+ SwitchPage(nActualMasterPageNum);
+ }
+
+ GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHPAGE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+}
+
+/*************************************************************************
+|*
+|* Verb auf OLE-Objekt anwenden
+|*
+\************************************************************************/
+
+
+ErrCode DrawViewShell::DoVerb(long nVerb)
+{
+ if ( mpDrawView->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ sal_uInt32 nInv = pObj->GetObjInventor();
+ sal_uInt16 nSdrObjKind = pObj->GetObjIdentifier();
+
+ if (nInv == SdrInventor && nSdrObjKind == OBJ_OLE2)
+ {
+ ActivateObject( (SdrOle2Obj*) pObj, nVerb);
+ }
+#ifdef STARIMAGE_AVAILABLE
+ else if (nInv = SdrInventor && nSdrObjKind == OBJ_GRAF &&
+ ((SdrGrafObj*) pObj)->GetGraphicType() == GRAPHIC_BITMAP &&
+ SFX_APP()->HasFeature(SFX_FEATURE_SIMAGE))
+ {
+ SdrGrafObj* pSdrGrafObj = (SdrGrafObj*) pObj;
+ short nOK = RET_YES;
+
+ if ( pSdrGrafObj->GetFileName().Len() )
+ {
+ // Graphik ist gelinkt, soll der Link aufgehoben werden?
+ QueryBox aBox(pWindow, WB_YES_NO | WB_DEF_YES,
+ String( SdResId(STR_REMOVE_LINK) ) );
+ nOK = aBox.Execute();
+
+ if (nOK == RET_YES)
+ {
+ // Link aufheben (File- und Filtername zuruecksetzen)
+ pSdrGrafObj->SetGraphicLink(String(), String());
+ }
+ }
+
+ if (nOK == RET_YES)
+ {
+ /**************************************************************
+ * OLE-Objekt erzeugen, StarImage starten
+ * Grafik-Objekt loeschen (durch OLE-Objekt ersetzt)
+ **************************************************************/
+ //HMHmpDrView->HideMarkHdl();
+
+ SvStorageRef aStor = new SvStorage(String());
+ SvInPlaceObjectRef aNewIPObj = &((SvFactory*)SvInPlaceObject::ClassFactory())
+ ->CreateAndInit(SimModuleDummy::GetID(SOFFICE_FILEFORMAT_CURRENT), aStor);
+ if ( aNewIPObj.Is() )
+ {
+ SdrGrafObj* pTempSdrGrafObj = (SdrGrafObj*) pSdrGrafObj->Clone ();
+
+ SvEmbeddedInfoObject * pInfo;
+ pInfo = GetViewFrame()->GetObjectShell()->
+ InsertObject( aNewIPObj, String() );
+
+ String aName;
+ if (pInfo)
+ {
+ aName = pInfo->GetObjName();
+ }
+
+ Rectangle aRect = pObj->GetLogicRect();
+ SdrOle2Obj* pSdrOle2Obj = new SdrOle2Obj( aNewIPObj,
+ aName, aRect );
+
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+
+ pPV->GetObjList()->InsertObject( pSdrOle2Obj );
+ mpDrawView->ReplaceObjectAtView( pObj, *pPV, pTempSdrGrafObj );
+
+ pSdrOle2Obj->SetLogicRect(aRect);
+ aNewIPObj->SetVisAreaSize(aRect.GetSize());
+
+ SimDLL::Update(aNewIPObj, pTempSdrGrafObj->GetGraphic(), pWindow);
+ ActivateObject(pSdrOle2Obj, SVVERB_SHOW);
+
+ Client* pClient = (Client*) GetIPClient();
+
+ if (pClient)
+ pClient->SetSdrGrafObj( pTempSdrGrafObj );
+ }
+ }
+ }
+#endif
+ }
+ }
+
+ return 0;
+}
+
+
+/*************************************************************************
+|*
+|* OLE-Object aktivieren
+|*
+\************************************************************************/
+
+sal_Bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
+{
+ sal_Bool bActivated = sal_False;
+
+ if ( !GetDocSh()->IsUIActive() )
+ {
+ ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager());
+
+ bActivated = ViewShell::ActivateObject(pObj, nVerb);
+
+ OSL_ASSERT(GetViewShell()!=NULL);
+ Client* pClient = static_cast<Client*>(GetViewShell()->GetIPClient());
+ if (pClient)
+ pClient->SetSdrGrafObj(NULL);
+ }
+
+ return(bActivated);
+}
+
+/*************************************************************************
+|*
+|* Auf gewuenschte Seite schalten
+|* Der Parameter nSelectedPage bezieht sich auf den aktuellen EditMode
+|*
+\************************************************************************/
+
+void LclResetFlag (bool& rbFlag) {rbFlag = false;}
+
+sal_Bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage)
+{
+ /** Under some circumstances there are nested calls to SwitchPage() and
+ may crash the application (activation of form controls when the
+ shell of the edit view is not on top of the shell stack, see issue
+ 83888 for details.) Therefore the nested calls are ignored (they
+ would jump to the wrong page anyway.)
+ */
+ if (mbIsInSwitchPage)
+ return sal_False;
+ mbIsInSwitchPage = true;
+ comphelper::ScopeGuard aGuard (::boost::bind(LclResetFlag, ::boost::ref(mbIsInSwitchPage)));
+
+ if (GetActiveWindow()->IsInPaint())
+ {
+ // Switching the current page while a Paint is being executed is
+ // dangerous. So, post it for later execution and return.
+ maAsynchronousSwitchPageCall.Post(::boost::bind(
+ ::std::mem_fun(&DrawViewShell::SwitchPage),
+ this,
+ nSelectedPage));
+ return sal_False;
+ }
+
+ sal_Bool bOK = sal_False;
+
+ // With the current implementation of FuSlideShow there is a problem
+ // when it dsplays the show in a window: When the show is stopped it
+ // returns at one point in time SDRPAGE_NOTFOUND as current page index.
+ // Because FuSlideShow is currently being rewritten this bug is fixed
+ // here.
+ // This is not as bad a hack as it may look because making SwitchPage()
+ // more robust with respect to invalid page numbers is a good thing
+ // anyway.
+ if (nSelectedPage == SDRPAGE_NOTFOUND)
+ {
+ nSelectedPage = 0;
+ }
+ else
+ {
+ // Make sure that the given page index points to an existing page. Move
+ // the index into the valid range if necessary.
+ sal_uInt16 nPageCount = (meEditMode == EM_PAGE)
+ ? GetDoc()->GetSdPageCount(mePageKind)
+ : GetDoc()->GetMasterSdPageCount(mePageKind);
+ if (nSelectedPage >= nPageCount)
+ nSelectedPage = nPageCount-1;
+ }
+
+ if (IsSwitchPageAllowed())
+ {
+ ModifyGuard aGuard2( GetDoc() );
+
+ bOK = sal_True;
+
+ if (mpActualPage)
+ {
+ SdPage* pNewPage = NULL;
+
+ if (meEditMode == EM_MASTERPAGE)
+ {
+ if( GetDoc()->GetMasterSdPageCount(mePageKind) > nSelectedPage )
+ pNewPage = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
+
+ if( pNewPage )
+ {
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+
+ String sPageText (pNewPage->GetLayoutName());
+ sPageText.Erase(sPageText.SearchAscii(SD_LT_SEPARATOR));
+ if (pPV
+ && pNewPage == dynamic_cast< SdPage* >( pPV->GetPage() )
+ && sPageText == maTabControl.GetPageText(nSelectedPage+1))
+ {
+ // this slide is already visible
+ return sal_True;
+ }
+ }
+ }
+ else
+ {
+ OSL_ASSERT(mpFrameView!=NULL);
+ mpFrameView->SetSelectedPage(nSelectedPage);
+
+ if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage)
+ pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
+
+ if (mpActualPage == pNewPage)
+ {
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+
+ SdPage* pCurrentPage = dynamic_cast< SdPage* >( pPV->GetPage());
+ if (pPV
+ && pNewPage == pCurrentPage
+ && pNewPage->GetName() == maTabControl.GetPageText(nSelectedPage+1))
+ {
+ // this slide is already visible
+ return sal_True;
+ }
+ }
+ }
+ }
+
+ if( mpDrawView )
+ mpDrawView->SdrEndTextEdit();
+
+ mpActualPage = NULL;
+
+ if (meEditMode == EM_PAGE)
+ {
+ mpActualPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
+ }
+ else
+ {
+ SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
+
+ // Passt die selektierte Seite zur MasterPage?
+ sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind);
+ for (sal_uInt16 i = 0; i < nPageCount; i++)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
+ if(pPage && pPage->IsSelected() && pMaster == &(pPage->TRG_GetMasterPage()))
+ {
+ mpActualPage = pPage;
+ break;
+ }
+ }
+
+ if (!mpActualPage)
+ {
+ // Die erste Seite nehmen, welche zur MasterPage passt
+ for (sal_uInt16 i = 0; i < nPageCount; i++)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
+ if(pPage && pMaster == &(pPage->TRG_GetMasterPage()))
+ {
+ mpActualPage = pPage;
+ break;
+ }
+ }
+ }
+ }
+
+ for (sal_uInt16 i = 0; i < GetDoc()->GetSdPageCount(mePageKind); i++)
+ {
+ // Alle Seiten deselektieren
+ GetDoc()->SetSelected( GetDoc()->GetSdPage(i, mePageKind), sal_False);
+ }
+
+ if (!mpActualPage)
+ {
+ // Sofern es keine mpActualPage gibt, wird die erste genommen
+ mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
+ }
+
+ // diese Seite auch selektieren (mpActualPage zeigt immer auf Zeichenseite,
+ // nie auf eine Masterpage)
+ GetDoc()->SetSelected(mpActualPage, sal_True);
+
+ rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
+ if( !xSlideshow.is() || !xSlideshow->isRunning() || ( xSlideshow->getAnimationMode() != ANIMATIONMODE_SHOW ) )
+ {
+ // VisArea zuziehen, um ggf. Objekte zu deaktivieren
+ // !!! only if we are not in presentation mode (#96279) !!!
+ OSL_ASSERT (GetViewShell()!=NULL);
+ GetViewShell()->DisconnectAllClients();
+ VisAreaChanged(Rectangle(Point(), Size(1, 1)));
+ }
+
+ if (meEditMode == EM_PAGE)
+ {
+ /**********************************************************************
+ * PAGEMODE
+ **********************************************************************/
+ GetDoc()->SetSelected(mpActualPage, sal_True);
+
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+
+ if (pPageView)
+ {
+ mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
+ mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
+ mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
+
+ if (mePageKind == PK_NOTES)
+ {
+ mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
+ }
+ else
+ {
+ mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
+ }
+ }
+
+ mpDrawView->HideSdrPage();
+ mpDrawView->ShowSdrPage(mpActualPage);
+ GetViewShellBase().GetDrawController().FireSwitchCurrentPage(mpActualPage);
+
+ SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
+
+ if (pNewPageView)
+ {
+ pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
+ pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
+ pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
+
+ if (mePageKind == PK_NOTES)
+ {
+ pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
+ }
+ else
+ {
+ pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
+ }
+ }
+
+ maTabControl.SetCurPageId(nSelectedPage+1);
+ String aPageName = mpActualPage->GetName();
+
+ if (maTabControl.GetPageText(nSelectedPage+1) != aPageName)
+ {
+ maTabControl.SetPageText(nSelectedPage+1, aPageName);
+ }
+ }
+ else
+ {
+ /**********************************************************************
+ * MASTERPAGE
+ **********************************************************************/
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+
+ if (pPageView)
+ {
+ mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
+ mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
+ mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
+
+ if (mePageKind == PK_NOTES)
+ {
+ mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
+ }
+ else
+ {
+ mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
+ }
+ }
+
+ mpDrawView->HideSdrPage();
+
+ SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
+
+ if( !pMaster ) // Falls es diese Page nicht geben sollte
+ pMaster = GetDoc()->GetMasterSdPage(0, mePageKind);
+
+ sal_uInt16 nNum = pMaster->GetPageNum();
+ mpDrawView->ShowSdrPage(mpDrawView->GetModel()->GetMasterPage(nNum));
+
+ GetViewShellBase().GetDrawController().FireSwitchCurrentPage(pMaster);
+
+ SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
+
+ if (pNewPageView)
+ {
+ pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
+ pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
+ pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
+
+ if (mePageKind == PK_NOTES)
+ {
+ pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
+ }
+ else
+ {
+ pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
+ }
+ }
+
+ String aLayoutName(pMaster->GetLayoutName());
+ aLayoutName.Erase(aLayoutName.SearchAscii(SD_LT_SEPARATOR));
+
+ maTabControl.SetCurPageId(nSelectedPage+1);
+
+ if (maTabControl.GetPageText(nSelectedPage+1) != aLayoutName)
+ {
+ maTabControl.SetPageText(nSelectedPage+1, aLayoutName);
+ }
+
+ if( mePageKind == PK_HANDOUT )
+ {
+ // set pages for all available handout presentation objects
+ sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList();
+ SdrObject* pObj = 0;
+
+ while( (pObj = rShapeList.getNextShape(pObj)) != 0 )
+ {
+ if( pMaster->GetPresObjKind(pObj) == PRESOBJ_HANDOUT )
+ {
+ // #i105146# We want no content to be displayed for PK_HANDOUT,
+ // so just never set a page as content
+ static_cast<SdrPageObj*>(pObj)->SetReferencedPage(0);
+ }
+ }
+ }
+ }
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ VisAreaChanged(aVisAreaWin);
+ mpDrawView->VisAreaChanged(GetActiveWindow());
+
+ // Damit der Navigator (und das Effekte-Window) das mitbekommt (/-men)
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, sal_True, sal_False);
+ rBindings.Invalidate(SID_STATUS_PAGE, sal_True, sal_False);
+ rBindings.Invalidate(SID_DELETE_MASTER_PAGE, sal_True, sal_False);
+ rBindings.Invalidate(SID_DELETE_PAGE, sal_True, sal_False);
+ rBindings.Invalidate(SID_ASSIGN_LAYOUT,sal_True,sal_False);
+ rBindings.Invalidate(SID_INSERTPAGE,sal_True,sal_False);
+ UpdatePreview( mpActualPage );
+
+ mpDrawView->AdjustMarkHdl();
+ }
+
+ return (bOK);
+}
+
+
+/*************************************************************************
+|*
+|* Pruefen, ob ein Seitenwechsel erlaubt ist
+|*
+\************************************************************************/
+
+sal_Bool DrawViewShell::IsSwitchPageAllowed() const
+{
+ bool bOK = true;
+
+ FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
+ if (pFormShell!=NULL && !pFormShell->PrepareClose (sal_False))
+ bOK = false;
+
+ return bOK;
+}
+
+/*************************************************************************
+|*
+|* neue aktuelle Seite auswaehlen, falls sich die Seitenfolge geaendert
+|* hat (z. B. durch Undo)
+|*
+\************************************************************************/
+
+void DrawViewShell::ResetActualLayer()
+{
+ LayerTabBar* pLayerBar = GetLayerTabControl();
+ if (pLayerBar != NULL)
+ {
+ // remember old layer cound and current layer id
+ // this is needed when one layer is renamed to
+ // restore current layer
+ sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount();
+ sal_uInt16 nOldLayerId = pLayerBar->GetCurPageId();
+
+ /*************************************************************
+ * Update fuer LayerTab
+ *************************************************************/
+ pLayerBar->Clear();
+
+ String aName;
+ String aActiveLayer = mpDrawView->GetActiveLayer();
+ String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) );
+ String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) );
+ String aLayoutLayer( SdResId(STR_LAYER_LAYOUT) );
+ String aControlsLayer( SdResId(STR_LAYER_CONTROLS) );
+ String aMeasureLinesLayer( SdResId(STR_LAYER_MEASURELINES) );
+ sal_uInt16 nActiveLayer = SDRLAYER_NOTFOUND;
+ SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
+ sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
+
+ for ( sal_uInt16 nLayer = 0; nLayer < nLayerCnt; nLayer++ )
+ {
+ aName = rLayerAdmin.GetLayer(nLayer)->GetName();
+
+ if ( aName == aActiveLayer )
+ {
+ nActiveLayer = nLayer;
+ }
+
+ if ( aName != aBackgroundLayer )
+ {
+ if (meEditMode == EM_MASTERPAGE)
+ {
+ // Layer der Page nicht auf MasterPage anzeigen
+ if (aName != aLayoutLayer &&
+ aName != aControlsLayer &&
+ aName != aMeasureLinesLayer)
+ {
+ pLayerBar->InsertPage(nLayer+1, aName);
+
+ TabBarPageBits nBits = 0;
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+
+ if (pPV && !pPV->IsLayerVisible(aName))
+ {
+ // Unsichtbare Layer werden anders dargestellt
+ nBits = TPB_SPECIAL;
+ }
+
+ pLayerBar->SetPageBits(nLayer+1, nBits);
+ }
+ }
+ else
+ {
+ // Layer der MasterPage nicht auf Page anzeigen
+ if ( aName != aBackgroundObjLayer )
+ {
+ pLayerBar->InsertPage(nLayer+1, aName);
+
+ TabBarPageBits nBits = 0;
+
+ if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName))
+ {
+ // Unsichtbare Layer werden anders dargestellt
+ nBits = TPB_SPECIAL;
+ }
+
+ pLayerBar->SetPageBits(nLayer+1, nBits);
+ }
+ }
+ }
+ }
+
+ if ( nActiveLayer == SDRLAYER_NOTFOUND )
+ {
+ if( nOldLayerCnt == pLayerBar->GetPageCount() )
+ {
+ nActiveLayer = nOldLayerId - 1;
+ }
+ else
+ {
+ nActiveLayer = ( meEditMode == EM_MASTERPAGE ) ? 2 : 0;
+ }
+
+ mpDrawView->SetActiveLayer( pLayerBar->GetPageText(nActiveLayer + 1) );
+ }
+
+ pLayerBar->SetCurPageId(nActiveLayer + 1);
+ GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER );
+ GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER );
+ }
+}
+
+/*************************************************************************
+|*
+|* Verzoegertes Close ausfuehren
+|*
+\************************************************************************/
+
+IMPL_LINK( DrawViewShell, CloseHdl, Timer*, pTimer )
+{
+ pTimer->Stop();
+ GetViewFrame()->GetBindings().Execute( SID_CLOSEWIN );
+ return 0L;
+}
+
+/*************************************************************************
+|*
+|* AcceptDrop
+|*
+\************************************************************************/
+
+sal_Int8 DrawViewShell::AcceptDrop (
+ const AcceptDropEvent& rEvt,
+ DropTargetHelper& rTargetHelper,
+ ::sd::Window* pTargetWindow,
+ sal_uInt16 nPage,
+ sal_uInt16 nLayer )
+{
+ if( nPage != SDRPAGE_NOTFOUND )
+ nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
+
+ if( SlideShow::IsRunning( GetViewShellBase() ) )
+ return DND_ACTION_NONE;
+
+ return mpDrawView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer );
+}
+
+/*************************************************************************
+|*
+|* ExecuteDrop
+|*
+\************************************************************************/
+
+sal_Int8 DrawViewShell::ExecuteDrop (
+ const ExecuteDropEvent& rEvt,
+ DropTargetHelper& rTargetHelper,
+ ::sd::Window* pTargetWindow,
+ sal_uInt16 nPage,
+ sal_uInt16 nLayer)
+{
+ if( nPage != SDRPAGE_NOTFOUND )
+ nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
+
+ if( SlideShow::IsRunning( GetViewShellBase() ) )
+ return DND_ACTION_NONE;
+
+ Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
+ sal_Int8 nResult (mpDrawView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ));
+ Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
+
+ return nResult;
+}
+
+} // end of namespace sd
+
+#ifdef _MSC_VER
+#if (_MSC_VER < 1400)
+#pragma optimize ( "", on )
+#endif
+#endif
+
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
new file mode 100755
index 000000000000..7c219331441b
--- /dev/null
+++ b/sd/source/ui/view/drviews2.cxx
@@ -0,0 +1,976 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include "ViewShellImplementation.hxx"
+#include <vcl/waitobj.hxx>
+#include <svx/svdograf.hxx>
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svx/svdpagv.hxx>
+#include <svx/svdundo.hxx>
+#ifndef _ZOOMITEM_HXX
+#include <svx/zoomitem.hxx>
+#endif
+#ifndef _EDITDATA_HXX
+#include <editeng/editdata.hxx>
+#endif
+#include <basic/sberrors.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/xfillit0.hxx>
+#include <svx/xflclit.hxx>
+#include <svl/aeitem.hxx>
+#include <editeng/eeitem.hxx>
+#include <basic/sbstar.hxx>
+#include <editeng/flditem.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xfillit0.hxx>
+
+#ifndef _SDOUTL_HXX //autogen
+#include <svx/svdoutl.hxx>
+#endif
+#include <svx/xlnwtit.hxx>
+#include <svx/svdoattr.hxx>
+#include <svx/xlnstwit.hxx>
+#include <svx/sdtmfitm.hxx>
+#include <svx/sdtagitm.hxx>
+#include <svx/xlnedwit.hxx>
+#include <svx/fontworkbar.hxx>
+
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+
+#include <sfx2/viewfrm.hxx>
+#include "sdgrffilter.hxx"
+
+#include "app.hrc"
+#include "glob.hrc"
+#include "helpids.h"
+#include "sdattr.hxx"
+#include "drawview.hxx"
+#include "Window.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "sdpage.hxx"
+#include "fuscale.hxx"
+#include "sdresid.hxx"
+#include "GraphicViewShell.hxx"
+#include "unmodpg.hxx"
+#include "slideshow.hxx"
+#include "fuvect.hxx"
+#include "stlpool.hxx"
+
+// #90356#
+#include "optsitem.hxx"
+#include "sdabstdlg.hxx"
+#include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
+#include <com/sun/star/drawing/XDrawPages.hpp>
+
+#include <strings.hrc>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* SfxRequests fuer temporaere Funktionen
+|*
+\************************************************************************/
+
+void DrawViewShell::FuTemporary(SfxRequest& rReq)
+{
+ // Waehrend einer Native-Diashow wird nichts ausgefuehrt!
+ if(SlideShow::IsRunning( GetViewShellBase() ) && (rReq.GetSlot() != SID_NAVIGATOR))
+ return;
+
+ DBG_ASSERT( mpDrawView, "sd::DrawViewShell::FuTemporary(), no draw view!" );
+ if( !mpDrawView )
+ return;
+
+ CheckLineTo (rReq);
+
+ DeactivateCurrentFunction();
+
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ // Slot wird gemapped (ToolboxImages/-Slots)
+ MapSlot( nSId );
+
+ switch ( nSId )
+ {
+ // Flaechen und Linien-Attribute:
+ // Sollten (wie StateMethode) eine eigene
+ // Execute-Methode besitzen
+ case SID_ATTR_FILL_STYLE:
+ case SID_ATTR_FILL_COLOR:
+ case SID_ATTR_FILL_GRADIENT:
+ case SID_ATTR_FILL_HATCH:
+ case SID_ATTR_FILL_BITMAP:
+ case SID_ATTR_FILL_SHADOW:
+
+ case SID_ATTR_LINE_STYLE:
+ case SID_ATTR_LINE_DASH:
+ case SID_ATTR_LINE_WIDTH:
+ case SID_ATTR_LINE_COLOR:
+ case SID_ATTR_LINEEND_STYLE:
+
+ case SID_ATTR_TEXT_FITTOSIZE:
+ {
+ if( rReq.GetArgs() )
+ {
+ sal_Bool bMergeUndo = sal_False;
+ ::svl::IUndoManager* pUndoManager = GetDocSh()->GetUndoManager();
+
+ // Anpassungen Start/EndWidth #63083#
+ if(nSId == SID_ATTR_LINE_WIDTH)
+ {
+ SdrObject* pObj = NULL;
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ sal_uLong nCount = rMarkList.GetMarkCount();
+
+ sal_Int32 nNewLineWidth = ((const XLineWidthItem&)rReq.GetArgs()->Get(XATTR_LINEWIDTH)).GetValue();
+
+ for (sal_uLong i=0; i<nCount; i++)
+ {
+ SfxItemSet aAttr(GetDoc()->GetPool());
+ pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ aAttr.Put(pObj->GetMergedItemSet());
+
+ sal_Int32 nActLineWidth = ((const XLineWidthItem&)aAttr.Get(XATTR_LINEWIDTH)).GetValue();
+
+ if(nActLineWidth != nNewLineWidth)
+ {
+ sal_Bool bSetItemSet(sal_False);
+
+ // #86265# do this for SFX_ITEM_DEFAULT and for SFX_ITEM_SET
+ if(SFX_ITEM_DONTCARE != aAttr.GetItemState(XATTR_LINESTARTWIDTH))
+ {
+ sal_Int32 nValAct = ((const XLineStartWidthItem&)aAttr.Get(XATTR_LINESTARTWIDTH)).GetValue();
+ sal_Int32 nValNew = nValAct + (((nNewLineWidth - nActLineWidth) * 15) / 10);
+ if(nValNew < 0)
+ nValNew = 0;
+ bSetItemSet = sal_True;
+ aAttr.Put(XLineStartWidthItem(nValNew));
+ }
+
+ // #86265# do this for SFX_ITEM_DEFAULT and for SFX_ITEM_SET
+ if(SFX_ITEM_DONTCARE != aAttr.GetItemState(XATTR_LINEENDWIDTH))
+ {
+ sal_Int32 nValAct = ((const XLineEndWidthItem&)aAttr.Get(XATTR_LINEENDWIDTH)).GetValue();
+ sal_Int32 nValNew = nValAct + (((nNewLineWidth - nActLineWidth) * 15) / 10);
+ if(nValNew < 0)
+ nValNew = 0;
+ bSetItemSet = sal_True;
+ aAttr.Put(XLineEndWidthItem(nValNew));
+ }
+
+ if(bSetItemSet)
+ pObj->SetMergedItemSet(aAttr);
+ }
+ }
+ }
+
+ if (nSId == SID_ATTR_FILL_SHADOW)
+ {
+ // Ggf. werden transparente Objekte wei?gefuellt
+ SdrObject* pObj = NULL;
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ sal_uLong nCount = rMarkList.GetMarkCount();
+
+ const bool bUndo = mpDrawView->IsUndoEnabled();
+
+ for (sal_uLong i=0; i<nCount; i++)
+ {
+ SfxItemSet aAttr(GetDoc()->GetPool());
+ pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ // #i25616#
+ if(!pObj->ISA(SdrGrafObj))
+ {
+ aAttr.Put(pObj->GetMergedItemSet());
+
+ const XFillStyleItem& rFillStyle =
+ (const XFillStyleItem&) aAttr.Get(XATTR_FILLSTYLE);
+
+ if (rFillStyle.GetValue() == XFILL_NONE)
+ {
+ if( bUndo )
+ {
+ // Vorlage hat keine Fuellung,
+ // daher hart attributieren: Fuellung setzen
+ if (!bMergeUndo)
+ {
+ bMergeUndo = sal_True;
+ pUndoManager->EnterListAction( String(), String() );
+ mpDrawView->BegUndo();
+ }
+
+ mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
+ }
+
+ aAttr.Put(XFillStyleItem(XFILL_SOLID));
+ aAttr.Put(XFillColorItem(String(), COL_WHITE));
+
+ pObj->SetMergedItemSet(aAttr);
+ }
+ }
+ }
+
+ if (bMergeUndo)
+ {
+ mpDrawView->EndUndo();
+ }
+ }
+
+ mpDrawView->SetAttributes(*rReq.GetArgs());
+
+ if (bMergeUndo)
+ {
+ pUndoManager->LeaveListAction();
+ }
+
+ rReq.Done();
+ }
+ else
+ {
+ switch( rReq.GetSlot() )
+ {
+ case SID_ATTR_FILL_SHADOW:
+ case SID_ATTR_FILL_STYLE:
+ case SID_ATTR_FILL_COLOR:
+ case SID_ATTR_FILL_GRADIENT:
+ case SID_ATTR_FILL_HATCH:
+ case SID_ATTR_FILL_BITMAP:
+ GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_AREA, SFX_CALLMODE_ASYNCHRON );
+ break;
+ case SID_ATTR_LINE_STYLE:
+ case SID_ATTR_LINE_DASH:
+ case SID_ATTR_LINE_WIDTH:
+ case SID_ATTR_LINE_COLOR:
+ GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_LINE, SFX_CALLMODE_ASYNCHRON );
+ break;
+ case SID_ATTR_TEXT_FITTOSIZE:
+ GetViewFrame()->GetDispatcher()->Execute( SID_TEXTATTR_DLG, SFX_CALLMODE_ASYNCHRON );
+ break;
+ }
+ }
+ Cancel();
+ }
+ break;
+
+ case SID_HYPHENATION:
+ {
+ // const SfxPoolItem* pItem = rReq.GetArg( SID_HYPHENATION );
+ // ^-- Soll so nicht benutzt werden (Defaults sind falsch) !
+ SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_HYPHENATION, sal_False);
+
+ if( pItem )
+ {
+ SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
+ sal_Bool bValue = ( (const SfxBoolItem*) pItem)->GetValue();
+ aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
+ mpDrawView->SetAttributes( aSet );
+ }
+ else // nur zum Test
+ {
+ DBG_ERROR(" Kein Wert fuer Silbentrennung!");
+ SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
+ sal_Bool bValue = sal_True;
+ aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
+ mpDrawView->SetAttributes( aSet );
+ }
+ rReq.Done();
+ Cancel();
+ }
+ break;
+
+ case SID_INSERTPAGE:
+ case SID_INSERTPAGE_QUICK:
+ case SID_DUPLICATE_PAGE:
+ {
+ SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage());
+ Cancel();
+ if(HasCurrentFunction(SID_BEZIER_EDIT) )
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+ if (pNewPage != NULL)
+ SwitchPage((pNewPage->GetPageNum()-1)/2);
+ rReq.Done ();
+ }
+ break;
+
+ case SID_INSERT_MASTER_PAGE:
+ {
+ // Use the API to create a new page.
+ Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier (
+ GetDoc()->getUnoModel(), UNO_QUERY);
+ if (xMasterPagesSupplier.is())
+ {
+ Reference<drawing::XDrawPages> xMasterPages (
+ xMasterPagesSupplier->getMasterPages());
+ if (xMasterPages.is())
+ {
+ sal_uInt16 nIndex = GetCurPageId();
+ xMasterPages->insertNewByIndex (nIndex);
+
+ // Create shapes for the default layout.
+ SdPage* pMasterPage = GetDoc()->GetMasterSdPage(
+ nIndex, PK_STANDARD);
+ pMasterPage->CreateTitleAndLayout (sal_True,sal_True);
+ }
+ }
+
+ Cancel();
+ if(HasCurrentFunction(SID_BEZIER_EDIT))
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+ rReq.Done ();
+ }
+ break;
+
+ case SID_MODIFYPAGE:
+ {
+ if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES ||
+ (mePageKind==PK_HANDOUT && meEditMode==EM_MASTERPAGE) )
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+ sal_uInt16 nPage = maTabControl.GetCurPageId() - 1;
+ mpActualPage = GetDoc()->GetSdPage(nPage, mePageKind);
+ ::sd::ViewShell::mpImpl->ProcessModifyPageSlot (
+ rReq,
+ mpActualPage,
+ mePageKind);
+ }
+
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_ASSIGN_LAYOUT:
+ {
+ if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES || (mePageKind==PK_HANDOUT && meEditMode==EM_MASTERPAGE))
+ {
+ if ( mpDrawView->IsTextEdit() )
+ mpDrawView->SdrEndTextEdit();
+
+ ::sd::ViewShell::mpImpl->AssignLayout(rReq, mePageKind);
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_RENAMEPAGE:
+ case SID_RENAME_MASTER_PAGE:
+ {
+ if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES )
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ sal_uInt16 nPageId = maTabControl.GetCurPageId();
+ SdPage* pCurrentPage = ( GetEditMode() == EM_PAGE )
+ ? GetDoc()->GetSdPage( nPageId - 1, GetPageKind() )
+ : GetDoc()->GetMasterSdPage( nPageId - 1, GetPageKind() );
+
+ String aTitle( SdResId( STR_TITLE_RENAMESLIDE ) );
+ String aDescr( SdResId( STR_DESC_RENAMESLIDE ) );
+ String aPageName = pCurrentPage->GetName();
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "Dialogdiet fail!");
+ AbstractSvxNameDialog* aNameDlg = pFact->CreateSvxNameDialog( GetActiveWindow(), aPageName, aDescr );
+ DBG_ASSERT(aNameDlg, "Dialogdiet fail!");
+ aNameDlg->SetText( aTitle );
+ aNameDlg->SetCheckNameHdl( LINK( this, DrawViewShell, RenameSlideHdl ), true );
+ aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
+
+ if( aNameDlg->Execute() == RET_OK )
+ {
+ String aNewName;
+ aNameDlg->GetName( aNewName );
+ if( ! aNewName.Equals( aPageName ) )
+ {
+#ifdef DBG_UTIL
+ bool bResult =
+#endif
+ RenameSlide( nPageId, aNewName );
+ DBG_ASSERT( bResult, "Couldn't rename slide" );
+ }
+ }
+ delete aNameDlg;
+ }
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_RENAMEPAGE_QUICK:
+ {
+ if (mePageKind==PK_STANDARD || mePageKind==PK_NOTES )
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ maTabControl.StartEditMode( maTabControl.GetCurPageId() );
+ }
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_PAGESIZE : // entweder dieses (kein menueeintrag o. ae. !!)
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs ();
+
+ if (pArgs)
+ if (pArgs->Count () == 3)
+ {
+ SFX_REQUEST_ARG (rReq, pWidth, SfxUInt32Item, ID_VAL_PAGEWIDTH, sal_False);
+ SFX_REQUEST_ARG (rReq, pHeight, SfxUInt32Item, ID_VAL_PAGEHEIGHT, sal_False);
+ SFX_REQUEST_ARG (rReq, pScaleAll, SfxBoolItem, ID_VAL_SCALEOBJECTS, sal_False);
+
+ Size aSize (pWidth->GetValue (), pHeight->GetValue ());
+
+ SetupPage (aSize, 0, 0, 0, 0, sal_True, sal_False, pScaleAll->GetValue ());
+ rReq.Ignore ();
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ rReq.Ignore ();
+ break;
+ }
+
+ case SID_PAGEMARGIN : // oder dieses (kein menueeintrag o. ae. !!)
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs ();
+
+ if (pArgs)
+ if (pArgs->Count () == 5)
+ {
+ SFX_REQUEST_ARG (rReq, pLeft, SfxUInt32Item, ID_VAL_PAGELEFT, sal_False);
+ SFX_REQUEST_ARG (rReq, pRight, SfxUInt32Item, ID_VAL_PAGERIGHT, sal_False);
+ SFX_REQUEST_ARG (rReq, pUpper, SfxUInt32Item, ID_VAL_PAGETOP, sal_False);
+ SFX_REQUEST_ARG (rReq, pLower, SfxUInt32Item, ID_VAL_PAGEBOTTOM, sal_False);
+ SFX_REQUEST_ARG (rReq, pScaleAll, SfxBoolItem, ID_VAL_SCALEOBJECTS, sal_False);
+
+ Size aEmptySize (0, 0);
+
+ SetupPage (aEmptySize, pLeft->GetValue (), pRight->GetValue (),
+ pUpper->GetValue (), pLower->GetValue (),
+ sal_False, sal_True, pScaleAll->GetValue ());
+ rReq.Ignore ();
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ rReq.Ignore ();
+ break;
+ }
+
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if (pArgs && pArgs->Count () == 1 )
+ {
+ SFX_REQUEST_ARG (rReq, pScale, SfxUInt16Item, SID_ATTR_ZOOMSLIDER, sal_False);
+ if (CHECK_RANGE (5, pScale->GetValue (), 3000))
+ {
+ SetZoom (pScale->GetValue ());
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_ATTR_ZOOM );
+ rBindings.Invalidate( SID_ZOOM_IN );
+ rBindings.Invalidate( SID_ZOOM_OUT );
+ rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
+
+ }
+ }
+
+ Cancel();
+ rReq.Done ();
+ break;
+ }
+ case SID_ZOOMING : // kein Menueintrag, sondern aus dem Zoomdialog generiert
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if (pArgs)
+ if (pArgs->Count () == 1)
+ {
+ SFX_REQUEST_ARG (rReq, pScale, SfxUInt32Item, ID_VAL_ZOOM, sal_False);
+ if (CHECK_RANGE (10, pScale->GetValue (), 1000))
+ {
+ SetZoom (pScale->GetValue ());
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_ATTR_ZOOM );
+ rBindings.Invalidate( SID_ZOOM_IN );
+ rBindings.Invalidate( SID_ZOOM_OUT );
+ rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
+ }
+ else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+
+ rReq.Ignore ();
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ rReq.Ignore ();
+ break;
+ }
+
+ case SID_ATTR_ZOOM:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ mbZoomOnPage = sal_False;
+
+ if ( pArgs )
+ {
+ SvxZoomType eZT = ( ( const SvxZoomItem& ) pArgs->
+ Get( SID_ATTR_ZOOM ) ).GetType();
+ switch( eZT )
+ {
+ case SVX_ZOOM_PERCENT:
+ SetZoom( (long) ( ( const SvxZoomItem& ) pArgs->
+ Get( SID_ATTR_ZOOM ) ).GetValue() );
+ break;
+
+ case SVX_ZOOM_OPTIMAL:
+ GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+ break;
+
+ case SVX_ZOOM_PAGEWIDTH:
+ GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+ break;
+
+ case SVX_ZOOM_WHOLEPAGE:
+ GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+ break;
+ case SVX_ZOOM_PAGEWIDTH_NOBORDER:
+ DBG_ERROR("sd::DrawViewShell::FuTemporary(), SVX_ZOOM_PAGEWIDTH_NOBORDER not handled!" );
+ break;
+ }
+ rReq.Ignore ();
+ }
+ else
+ {
+ // hier den Zoom-Dialog oeffnen
+ SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ }
+ Cancel();
+ }
+ break;
+
+ case SID_CHANGEBEZIER:
+ case SID_CHANGEPOLYGON:
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+ }
+
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ if( rReq.GetSlot() == SID_CHANGEBEZIER )
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->ConvertMarkedToPathObj(sal_False);
+ }
+ else
+ {
+ if( mpDrawView->IsVectorizeAllowed() )
+ SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ else
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->ConvertMarkedToPolyObj(sal_False);
+ }
+ }
+
+ Invalidate(SID_CHANGEBEZIER);
+ Invalidate(SID_CHANGEPOLYGON);
+ }
+ Cancel();
+
+ if( HasCurrentFunction(SID_BEZIER_EDIT) )
+ { // ggf. die richtige Editfunktion aktivieren
+ GetViewFrame()->GetDispatcher()->Execute(SID_SWITCH_POINTEDIT,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+ }
+ rReq.Ignore ();
+ break;
+
+ case SID_CONVERT_TO_CONTOUR:
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+ }
+
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->ConvertMarkedToPathObj(sal_True);
+
+ Invalidate(SID_CONVERT_TO_CONTOUR);
+ }
+ Cancel();
+
+ rReq.Ignore ();
+ break;
+
+ case SID_CONVERT_TO_METAFILE:
+ case SID_CONVERT_TO_BITMAP:
+ {
+ // End text edit mode when it is active because the metafile or
+ // bitmap that will be created does not support it.
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+ }
+
+ if ( mpDrawView->IsPresObjSelected(true,true,true) )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+
+ // switch on undo for the next operations
+ mpDrawView->BegUndo(
+ String(
+ SdResId (nSId==SID_CONVERT_TO_METAFILE ? STR_UNDO_CONVERT_TO_METAFILE : STR_UNDO_CONVERT_TO_BITMAP)));
+
+ // create SdrGrafObj from metafile/bitmap
+ Graphic aGraphic;
+ switch (nSId)
+ {
+ case SID_CONVERT_TO_METAFILE:
+ {
+ GDIMetaFile aMetaFile(mpDrawView->GetAllMarkedMetaFile ());
+ aGraphic = Graphic(aMetaFile);
+ }
+ break;
+ case SID_CONVERT_TO_BITMAP:
+ {
+ Bitmap aBitmap (mpDrawView->GetAllMarkedBitmap ());
+ aGraphic = Graphic(aBitmap);
+ }
+ break;
+ }
+
+ // create new object
+ SdrGrafObj* pGraphicObj = new SdrGrafObj (aGraphic);
+
+ // get some necessary info and ensure it
+ const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList());
+ const sal_uInt32 nMarkCount(rMarkList.GetMarkCount());
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+ OSL_ENSURE(nMarkCount, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP with empty selection (!)");
+ OSL_ENSURE(pPageView, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP without SdrPageView (!)");
+
+ // fit rectangle of new graphic object to selection's mark rect
+ Rectangle aAllMarkedRect;
+ rMarkList.TakeBoundRect(pPageView, aAllMarkedRect);
+ pGraphicObj->SetLogicRect(aAllMarkedRect);
+
+ // #i71540# to keep the order, it is necessary to replace the lowest object
+ // of the selection with the new object. This also means that with multi
+ // selection, all other objects need to be deleted first
+ SdrMark* pFirstMark = rMarkList.GetMark(0L);
+ SdrObject* pReplacementCandidate = pFirstMark->GetMarkedSdrObj();
+
+ if(nMarkCount > 1L)
+ {
+ // take first object out of selection
+ mpDrawView->MarkObj(pReplacementCandidate, pPageView, true, true);
+
+ // clear remaining selection
+ mpDrawView->DeleteMarkedObj();
+ }
+
+ // now replace lowest object with new one
+ mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj);
+
+ // switch off undo
+ mpDrawView->EndUndo();
+ }
+ }
+
+ Cancel();
+
+ rReq.Done ();
+ break;
+
+ case SID_SET_DEFAULT:
+ {
+ SfxItemSet* pSet = NULL;
+
+ if (mpDrawView->IsTextEdit())
+ {
+ ::Outliner* pOutl = mpDrawView->GetTextEditOutliner();
+ if (pOutl)
+ {
+ pOutl->RemoveFields(sal_True, (TypeId) SvxURLField::StaticType());
+ }
+
+ pSet = new SfxItemSet( GetPool(), EE_ITEMS_START, EE_ITEMS_END );
+ mpDrawView->SetAttributes( *pSet, sal_True );
+ }
+ else
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ sal_uLong nCount = rMarkList.GetMarkCount();
+
+ // In diese Liste werden fuer jedes Praesentationsobjekt ein SfxItemSet
+ // der harten Attribute sowie der UserCall eingetragen, da diese beim nachfolgenden
+ // mpDrawView->SetAttributes( *pSet, sal_True ) verloren gehen und spaeter restauriert
+ // werden muessen
+ List* pAttrList = new List();
+ SdPage* pPresPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
+ sal_uLong i;
+
+ for ( i = 0; i < nCount; i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ if( pPresPage->IsPresObj( pObj ) )
+ {
+ SfxItemSet* pNewSet = new SfxItemSet( GetDoc()->GetPool(), SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT, 0 );
+ pNewSet->Put(pObj->GetMergedItemSet());
+ pAttrList->Insert( pNewSet, LIST_APPEND );
+ pAttrList->Insert( pObj->GetUserCall(), LIST_APPEND );
+ }
+ }
+
+ pSet = new SfxItemSet( GetPool() );
+ mpDrawView->SetAttributes( *pSet, sal_True );
+
+ sal_uLong j = 0;
+
+ for ( i = 0; i < nCount; i++ )
+ {
+ SfxStyleSheet* pSheet = NULL;
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ if (pObj->GetObjIdentifier() == OBJ_TITLETEXT)
+ {
+ pSheet = mpActualPage->GetStyleSheetForPresObj(PRESOBJ_TITLE);
+ if (pSheet)
+ pObj->SetStyleSheet(pSheet, sal_False);
+ }
+ else if(pObj->GetObjIdentifier() == OBJ_OUTLINETEXT)
+ {
+ for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
+ {
+ pSheet = mpActualPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
+ DBG_ASSERT(pSheet, "Vorlage fuer Gliederungsobjekt nicht gefunden");
+ if (pSheet)
+ {
+ pObj->StartListening(*pSheet);
+
+ if( nLevel == 1 )
+ // Textrahmen hoert auf StyleSheet der Ebene1
+ pObj->NbcSetStyleSheet(pSheet, sal_False);
+
+ }
+ }
+ }
+
+ if( pPresPage->IsPresObj( pObj ) )
+ {
+ SfxItemSet* pNewSet = (SfxItemSet*) pAttrList->GetObject(j++);
+ SdrObjUserCall* pUserCall = (SdrObjUserCall*) pAttrList->GetObject(j++);
+
+ if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_MINFRAMEHEIGHT ) == SFX_ITEM_ON )
+ {
+ pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_MINFRAMEHEIGHT));
+ }
+
+ if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) == SFX_ITEM_ON )
+ {
+ pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_AUTOGROWHEIGHT));
+ }
+
+ if( pUserCall )
+ pObj->SetUserCall( pUserCall );
+
+ delete pNewSet;
+ }
+ }
+
+ delete pAttrList;
+ }
+
+ delete pSet;
+ Cancel();
+ }
+ break;
+
+ case SID_DELETE_SNAPITEM:
+ {
+ SdrPageView* pPV;
+ Point aMPos = GetActiveWindow()->PixelToLogic( maMousePos );
+ sal_uInt16 nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic( Size(
+ FuPoor::HITPIX, 0 ) ).Width();
+ sal_uInt16 nHelpLine;
+
+ mbMousePosFreezed = sal_False;
+
+ if( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
+ {
+ pPV->DeleteHelpLine( nHelpLine );
+ }
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_DELETE_PAGE:
+ case SID_DELETE_MASTER_PAGE:
+ DeleteActualPage();
+ Cancel();
+ rReq.Ignore ();
+ break;
+
+ case SID_DELETE_LAYER:
+ DeleteActualLayer();
+ Cancel();
+ rReq.Ignore ();
+ break;
+
+ case SID_ORIGINAL_SIZE:
+ mpDrawView->SetMarkedOriginalSize();
+ Cancel();
+ rReq.Done();
+ break;
+
+ case SID_DRAW_FONTWORK:
+ case SID_DRAW_FONTWORK_VERTICAL:
+ {
+ svx::FontworkBar::execute( mpView, rReq, GetViewFrame()->GetBindings() ); // SJ: can be removed (I think)
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_SAVEGRAPHIC:
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrGrafObj *pGrafObj = dynamic_cast< SdrGrafObj* >( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
+ if(pGrafObj )
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape( pGrafObj->getUnoShape(), com::sun::star::uno::UNO_QUERY );
+ SdGRFFilter::SaveGraphic( xShape );
+ }
+ }
+ Cancel();
+ rReq.Ignore();
+ }
+ break;
+
+ default:
+ {
+ // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
+ // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp01 (drviews8)
+ // gewandert.
+ FuTemp01(rReq);
+ }
+ break;
+ }
+
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->Activate();
+ }
+}
+
+
+
+
+/** This method consists basically of three parts:
+ 1. Process the arguments of the SFX request.
+ 2. Use the model to create a new page or duplicate an existing one.
+ 3. Update the tab control and switch to the new page.
+*/
+SdPage* DrawViewShell::CreateOrDuplicatePage (
+ SfxRequest& rRequest,
+ PageKind ePageKind,
+ SdPage* pPage,
+ const sal_Int32 nInsertPosition)
+{
+ SdPage* pNewPage = NULL;
+ if (ePageKind == PK_STANDARD && meEditMode != EM_MASTERPAGE)
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+ pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage, nInsertPosition);
+ }
+ return pNewPage;
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx
new file mode 100755
index 000000000000..d632929a3f65
--- /dev/null
+++ b/sd/source/ui/view/drviews3.cxx
@@ -0,0 +1,950 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+
+#include <sfx2/viewfrm.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/protitem.hxx>
+#include <editeng/frmdiritem.hxx>
+#include <svx/ruler.hxx>
+#ifndef _SVX_RULERITEM_HXX
+#include <svx/rulritem.hxx>
+#endif
+#include <svx/zoomitem.hxx>
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svx/svdpagv.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <tools/urlobj.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/eitem.hxx>
+#include <svl/rectitem.hxx>
+#include <svl/stritem.hxx>
+#include <svx/svdoole2.hxx>
+#include <svl/itempool.hxx>
+#include <svl/ptitem.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sberrors.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/f3dchild.hxx>
+#include <svx/float3d.hxx>
+#include "optsitem.hxx"
+
+#include "app.hrc"
+#include "glob.hrc"
+#include "strings.hrc"
+#include "res_bmp.hrc"
+
+#include "sdundogr.hxx"
+#include "undopage.hxx"
+#include "glob.hxx"
+#include "app.hxx"
+#include "fupoor.hxx"
+#include "slideshow.hxx"
+#ifndef SD_FRAME_VIEW
+#include "FrameView.hxx"
+#endif
+#include "sdpage.hxx"
+#include "Window.hxx"
+#include "sdresid.hxx"
+#include "drawview.hxx"
+#include "drawdoc.hxx"
+#include "DrawViewShell.hxx"
+#include "Ruler.hxx"
+#include "DrawDocShell.hxx"
+#include "headerfooterdlg.hxx"
+#include "masterlayoutdlg.hxx"
+#include "Ruler.hxx"
+#include "DrawDocShell.hxx"
+#include "sdabstdlg.hxx"
+#include <sfx2/ipclient.hxx>
+#include <tools/diagnose_ex.h>
+#include "ViewShellBase.hxx"
+#include "FormShellManager.hxx"
+#include "LayerTabBar.hxx"
+#include "sdabstdlg.hxx"
+#include "sdpage.hxx"
+#include <com/sun/star/drawing/framework/XControllerManager.hpp>
+#include <com/sun/star/drawing/framework/XConfigurationController.hpp>
+#include <com/sun/star/drawing/framework/XConfiguration.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing::framework;
+using ::com::sun::star::frame::XFrame;
+using ::com::sun::star::frame::XController;
+
+namespace sd {
+
+#ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
+#define SO2_DECL_SVINPLACEOBJECT_DEFINED
+SO2_DECL_REF(SvInPlaceObject)
+#endif
+
+
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Controller bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecCtrl(SfxRequest& rReq)
+{
+ // waehrend einer Diashow wird nichts ausser dem Seitenwechsel und dem
+ // Sprung zur Bookmark ausgefuehrt!
+ if( HasCurrentFunction(SID_PRESENTATION) &&
+ rReq.GetSlot() != SID_SWITCHPAGE &&
+ rReq.GetSlot() != SID_JUMPTOMARK)
+ return;
+
+ CheckLineTo (rReq);
+
+ // End text edit mode for some requests.
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch (nSlot)
+ {
+ case SID_OUTPUT_QUALITY_COLOR:
+ case SID_OUTPUT_QUALITY_GRAYSCALE:
+ case SID_OUTPUT_QUALITY_BLACKWHITE:
+ case SID_OUTPUT_QUALITY_CONTRAST:
+ // Do nothing.
+ break;
+ default:
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+ }
+
+ // sal_uInt16 nSlot = rReq.GetSlot();
+ switch (nSlot)
+ {
+ case SID_SWITCHPAGE: // BASIC
+ {
+ sal_Bool bWasBasic = sal_False;
+
+ // switch page in running slide show
+ if(SlideShow::IsRunning(GetViewShellBase()) && rReq.GetArgs())
+ {
+ SFX_REQUEST_ARG(rReq, pWhatPage, SfxUInt32Item, ID_VAL_WHATPAGE, sal_False);
+ SlideShow::GetSlideShow(GetViewShellBase())->jumpToPageNumber((sal_Int32)((pWhatPage->GetValue()-1)>>1));
+ }
+ else
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs ();
+ sal_uInt16 nSelectedPage = 0;
+
+ if (! pArgs)
+ {
+ nSelectedPage = maTabControl.GetCurPageId() - 1;
+ }
+ else if (pArgs->Count () == 2)
+ {
+ SFX_REQUEST_ARG (rReq, pWhatPage, SfxUInt32Item, ID_VAL_WHATPAGE, sal_False);
+ SFX_REQUEST_ARG (rReq, pWhatKind, SfxUInt32Item, ID_VAL_WHATKIND, sal_False);
+
+ sal_Int32 nWhatPage = (sal_Int32)pWhatPage->GetValue ();
+ sal_Int32 nWhatKind = (sal_Int32)pWhatKind->GetValue ();
+ if (! CHECK_RANGE (PK_STANDARD, nWhatKind, PK_HANDOUT))
+ {
+ StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+ rReq.Ignore ();
+ break;
+ }
+ else if (meEditMode != EM_MASTERPAGE)
+ {
+ if (! CHECK_RANGE (0, nWhatPage, GetDoc()->GetSdPageCount((PageKind)nWhatKind)))
+ {
+ StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+ rReq.Ignore ();
+ break;
+ }
+
+ nSelectedPage = (short) nWhatPage;
+ mePageKind = (PageKind) nWhatKind;
+ bWasBasic = sal_True;
+ }
+ }
+ else
+ {
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ rReq.Ignore ();
+ break;
+ }
+
+
+ if( GetDocSh() && (GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED))
+ GetDocSh()->SetModified();
+
+ SwitchPage(nSelectedPage);
+
+ if(HasCurrentFunction(SID_BEZIER_EDIT))
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+
+ Invalidate();
+ InvalidateWindows();
+ rReq.Done ();
+ }
+ break;
+ }
+
+ case SID_SWITCHLAYER: // BASIC
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs ();
+ sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId ();
+
+ if( pArgs && pArgs->Count () == 1)
+ {
+ SFX_REQUEST_ARG (rReq, pWhatLayer, SfxUInt32Item, ID_VAL_WHATLAYER, sal_False);
+ if( pWhatLayer )
+ nCurPage = (short) pWhatLayer->GetValue ();
+ }
+
+ mpDrawView->SetActiveLayer( GetLayerTabControl()->GetPageText(nCurPage) );
+ Invalidate();
+ rReq.Done ();
+
+ break;
+ }
+
+ case SID_PAGEMODE: // BASIC
+ {
+
+ const SfxItemSet *pArgs = rReq.GetArgs ();
+
+ if ( pArgs && pArgs->Count () == 2)
+ {
+ SFX_REQUEST_ARG (rReq, pIsActive, SfxBoolItem, ID_VAL_ISACTIVE, sal_False);
+ SFX_REQUEST_ARG (rReq, pWhatKind, SfxUInt32Item, ID_VAL_WHATKIND, sal_False);
+
+ sal_Int32 nWhatKind = (sal_Int32)pWhatKind->GetValue ();
+ if (CHECK_RANGE (PK_STANDARD, nWhatKind, PK_HANDOUT))
+ {
+ mbIsLayerModeActive = pIsActive->GetValue ();
+ mePageKind = (PageKind) nWhatKind;
+ }
+ }
+
+ // Default-Layer der Page einschalten
+ mpDrawView->SetActiveLayer( String( SdResId(STR_LAYER_LAYOUT) ) );
+
+ ChangeEditMode(EM_PAGE, mbIsLayerModeActive);
+
+ Invalidate();
+ rReq.Done ();
+
+ break;
+ }
+
+ case SID_LAYERMODE: // BASIC
+ {
+ const SfxItemSet *pArgs = rReq.GetArgs ();
+
+ if ( pArgs && pArgs->Count () == 2)
+ {
+ SFX_REQUEST_ARG (rReq, pWhatLayerMode, SfxBoolItem, ID_VAL_ISACTIVE, sal_False);
+ SFX_REQUEST_ARG (rReq, pWhatLayer, SfxUInt32Item, ID_VAL_WHATLAYER, sal_False);
+
+ sal_Int32 nWhatLayer = (sal_Int32)pWhatLayer->GetValue ();
+ if (CHECK_RANGE (EM_PAGE, nWhatLayer, EM_MASTERPAGE))
+ {
+ mbIsLayerModeActive = pWhatLayerMode->GetValue ();
+ meEditMode = (EditMode) nWhatLayer;
+ }
+ }
+
+ ChangeEditMode(meEditMode, !mbIsLayerModeActive);
+
+ Invalidate();
+ rReq.Done ();
+
+ break;
+ }
+
+ case SID_HEADER_AND_FOOTER:
+ case SID_INSERT_PAGE_NUMBER:
+ case SID_INSERT_DATE_TIME:
+ {
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ AbstractHeaderFooterDialog* pDlg = pFact ? pFact->CreateHeaderFooterDialog( (::ViewShell*)this, GetActiveWindow(), GetDoc(), mpActualPage ) : 0;
+ if( pDlg )
+ {
+ pDlg->Execute();
+ delete pDlg;
+
+ GetActiveWindow()->Invalidate();
+ UpdatePreview( mpActualPage );
+ }
+
+ Invalidate();
+ rReq.Done ();
+
+ break;
+ }
+
+ case SID_MASTER_LAYOUTS:
+ {
+ SdPage* pPage = GetActualPage();
+ if (meEditMode == EM_MASTERPAGE)
+ // Use the master page of the current page.
+ pPage = static_cast<SdPage*>(&pPage->TRG_GetMasterPage());
+
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ VclAbstractDialog* pDlg = pFact ? pFact->CreateMasterLayoutDialog( GetActiveWindow(), GetDoc(), pPage ) : 0;
+ if( pDlg )
+ {
+ pDlg->Execute();
+ delete pDlg;
+ Invalidate();
+ }
+ rReq.Done ();
+ break;
+ }
+ case SID_OBJECTRESIZE:
+ {
+ /******************************************************************
+ * Der Server moechte die Clientgrosse verandern
+ ******************************************************************/
+ OSL_ASSERT (GetViewShell()!=NULL);
+ SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
+
+ if ( pIPClient && pIPClient->IsObjectInPlaceActive() )
+ {
+ const SfxRectangleItem& rRect =
+ (SfxRectangleItem&)rReq.GetArgs()->Get(SID_OBJECTRESIZE);
+ Rectangle aRect( GetActiveWindow()->PixelToLogic( rRect.GetValue() ) );
+
+ if ( mpDrawView->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( pObj );
+ if(pOle2Obj)
+ {
+ if( pOle2Obj->GetObjRef().is() )
+ {
+ pOle2Obj->SetLogicRect(aRect);
+ }
+ }
+ }
+ }
+ }
+ rReq.Ignore ();
+ break;
+ }
+
+ case SID_RELOAD:
+ {
+ // #83951#
+ sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
+ SfxViewFrame* pFrame = GetViewFrame();
+
+ try
+ {
+ Reference< XFrame > xFrame( pFrame->GetFrame().GetFrameInterface(), UNO_SET_THROW );
+
+ // Save the current configuration of panes and views.
+ Reference<XControllerManager> xControllerManager (
+ GetViewShellBase().GetController(), UNO_QUERY_THROW);
+ Reference<XConfigurationController> xConfigurationController (
+ xControllerManager->getConfigurationController(), UNO_QUERY_THROW );
+ Reference<XConfiguration> xConfiguration (
+ xConfigurationController->getRequestedConfiguration(), UNO_SET_THROW );
+
+ SfxChildWindow* pWindow = pFrame->GetChildWindow(nId);
+ if(pWindow)
+ {
+ Svx3DWin* p3DWin = (Svx3DWin*)(pWindow->GetWindow());
+ if(p3DWin)
+ p3DWin->DocumentReload();
+ }
+
+ // Normale Weiterleitung an ViewFrame zur Ausfuehrung
+ GetViewFrame()->ExecuteSlot(rReq);
+
+ // From here on we must cope with this object and the frame already being
+ // deleted. Do not call any methods or use data members.
+ Reference<XController> xController( xFrame->getController(), UNO_SET_THROW );
+
+ // Restore the configuration.
+ xControllerManager = Reference<XControllerManager>( xController, UNO_QUERY_THROW);
+ xConfigurationController = Reference<XConfigurationController>(
+ xControllerManager->getConfigurationController());
+ if ( ! xConfigurationController.is())
+ throw RuntimeException();
+ xConfigurationController->restoreConfiguration(xConfiguration);
+ }
+ catch (RuntimeException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ // We have to return immediately to avoid accessing this object.
+ return;
+ }
+
+ case SID_JUMPTOMARK:
+ {
+ if( rReq.GetArgs() )
+ {
+ SFX_REQUEST_ARG(rReq, pBookmark, SfxStringItem, SID_JUMPTOMARK, sal_False);
+
+ if (pBookmark)
+ {
+ UniString sBookmark( INetURLObject::decode( pBookmark->GetValue(), '%', INetURLObject::DECODE_WITH_CHARSET ) );
+
+ rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if(xSlideshow.is() && xSlideshow->isRunning())
+ {
+ xSlideshow->jumpToBookmark(sBookmark);
+ }
+ else
+ {
+ GotoBookmark( sBookmark );
+ }
+ }
+ }
+ rReq.Done();
+ break;
+ }
+
+ case SID_OUTPUT_QUALITY_COLOR:
+ case SID_OUTPUT_QUALITY_GRAYSCALE:
+ case SID_OUTPUT_QUALITY_BLACKWHITE:
+ case SID_OUTPUT_QUALITY_CONTRAST:
+ {
+ ExecReq( rReq );
+ break;
+ }
+
+ case SID_MAIL_SCROLLBODY_PAGEDOWN:
+ {
+ ExecReq( rReq );
+ break;
+ }
+
+ case SID_ATTR_YEAR2000:
+ {
+ FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
+ if (pFormShell != NULL)
+ {
+ const SfxPoolItem* pItem;
+ if (rReq.GetArgs()->GetItemState(
+ SID_ATTR_YEAR2000, sal_True, &pItem) == SFX_ITEM_SET)
+ pFormShell->SetY2KState (
+ static_cast<const SfxUInt16Item*>(pItem)->GetValue());
+ }
+
+ rReq.Done();
+ }
+ break;
+
+ case SID_OPT_LOCALE_CHANGED:
+ {
+ GetActiveWindow()->Invalidate();
+ UpdatePreview( mpActualPage );
+ rReq.Done();
+ }
+
+ default:
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Lineale bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecRuler(SfxRequest& rReq)
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if(HasCurrentFunction(SID_PRESENTATION))
+ return;
+
+ CheckLineTo (rReq);
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ const Point aPagePos( GetActiveWindow()->GetViewOrigin() );
+ Size aPageSize = mpActualPage->GetSize();
+ Size aViewSize = GetActiveWindow()->GetViewSize();
+ SdUndoGroup* pUndoGroup = NULL;
+
+ if ( rReq.GetSlot() == SID_ATTR_LONG_LRSPACE ||
+ rReq.GetSlot() == SID_ATTR_LONG_ULSPACE )
+ {
+ pUndoGroup = new SdUndoGroup(GetDoc());
+ String aString(SdResId(STR_UNDO_CHANGE_PAGEBORDER));
+ pUndoGroup->SetComment(aString);
+ }
+
+ switch ( rReq.GetSlot() )
+ {
+ case SID_ATTR_LONG_LRSPACE:
+ {
+ const SvxLongLRSpaceItem& rLRSpace = (const SvxLongLRSpaceItem&)
+ pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_LRSPACE));
+
+ if( mpDrawView->IsTextEdit() )
+ {
+ Rectangle aRect = maMarkRect;
+ aRect.SetPos(aRect.TopLeft() + aPagePos);
+ aRect.Left() = rLRSpace.GetLeft();
+ aRect.Right() = aViewSize.Width() - rLRSpace.GetRight();
+ aRect.SetPos(aRect.TopLeft() - aPagePos);
+ if ( aRect != maMarkRect)
+ {
+ mpDrawView->SetAllMarkedRect(aRect);
+ maMarkRect = mpDrawView->GetAllMarkedRect();
+ Invalidate( SID_RULER_OBJECT );
+ }
+ }
+ else
+ {
+ long nLeft = Max(0L, rLRSpace.GetLeft() - aPagePos.X());
+ long nRight = Max(0L, rLRSpace.GetRight() + aPagePos.X() +
+ aPageSize.Width() - aViewSize.Width());
+
+ sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
+ sal_uInt16 i;
+ for ( i = 0; i < nPageCnt; i++)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
+ SdUndoAction* pUndo = new SdPageLRUndoAction(GetDoc(),
+ pPage,
+ pPage->GetLftBorder(),
+ pPage->GetRgtBorder(),
+ nLeft, nRight);
+ pUndoGroup->AddAction(pUndo);
+ pPage->SetLftBorder(nLeft);
+ pPage->SetRgtBorder(nRight);
+ }
+ nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
+
+ for (i = 0; i < nPageCnt; i++)
+ {
+ SdPage* pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
+ SdUndoAction* pUndo = new SdPageLRUndoAction(GetDoc(),
+ pPage,
+ pPage->GetLftBorder(),
+ pPage->GetRgtBorder(),
+ nLeft, nRight);
+ pUndoGroup->AddAction(pUndo);
+ pPage->SetLftBorder(nLeft);
+ pPage->SetRgtBorder(nRight);
+ }
+ InvalidateWindows();
+ }
+ break;
+ }
+ case SID_ATTR_LONG_ULSPACE:
+ {
+ const SvxLongULSpaceItem& rULSpace = (const SvxLongULSpaceItem&)
+ pArgs->Get(GetPool().GetWhich(SID_ATTR_LONG_ULSPACE));
+
+ if( mpDrawView->IsTextEdit() )
+ {
+ Rectangle aRect = maMarkRect;
+ aRect.SetPos(aRect.TopLeft() + aPagePos);
+ aRect.Top() = rULSpace.GetUpper();
+ aRect.Bottom() = aViewSize.Height() - rULSpace.GetLower();
+ aRect.SetPos(aRect.TopLeft() - aPagePos);
+
+ if ( aRect != maMarkRect)
+ {
+ mpDrawView->SetAllMarkedRect(aRect);
+ maMarkRect = mpDrawView->GetAllMarkedRect();
+ Invalidate( SID_RULER_OBJECT );
+ }
+ }
+ else
+ {
+ long nUpper = Max(0L, rULSpace.GetUpper() - aPagePos.Y());
+ long nLower = Max(0L, rULSpace.GetLower() + aPagePos.Y() +
+ aPageSize.Height() - aViewSize.Height());
+
+ sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
+ sal_uInt16 i;
+ for ( i = 0; i < nPageCnt; i++)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
+ SdUndoAction* pUndo = new SdPageULUndoAction(GetDoc(),
+ pPage,
+ pPage->GetUppBorder(),
+ pPage->GetLwrBorder(),
+ nUpper, nLower);
+ pUndoGroup->AddAction(pUndo);
+ pPage->SetUppBorder(nUpper);
+ pPage->SetLwrBorder(nLower);
+ }
+ nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
+
+ for (i = 0; i < nPageCnt; i++)
+ {
+ SdPage* pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
+ SdUndoAction* pUndo = new SdPageULUndoAction(GetDoc(),
+ pPage,
+ pPage->GetUppBorder(),
+ pPage->GetLwrBorder(),
+ nUpper, nLower);
+ pUndoGroup->AddAction(pUndo);
+ pPage->SetUppBorder(nUpper);
+ pPage->SetLwrBorder(nLower);
+ }
+ InvalidateWindows();
+ }
+ break;
+ }
+
+ case SID_RULER_OBJECT:
+ {
+ Rectangle aRect = maMarkRect;
+ aRect.SetPos(aRect.TopLeft() + aPagePos);
+
+ const SvxObjectItem& rOI = (const SvxObjectItem&)
+ pArgs->Get(GetPool().GetWhich(SID_RULER_OBJECT));
+
+ if ( rOI.GetStartX() != rOI.GetEndX() )
+ {
+ aRect.Left() = rOI.GetStartX();
+ aRect.Right() = rOI.GetEndX();
+ }
+ if ( rOI.GetStartY() != rOI.GetEndY() )
+ {
+ aRect.Top() = rOI.GetStartY();
+ aRect.Bottom() = rOI.GetEndY();
+ }
+ aRect.SetPos(aRect.TopLeft() - aPagePos);
+ if ( aRect != maMarkRect)
+ {
+ mpDrawView->SetAllMarkedRect(aRect);
+ maMarkRect = mpDrawView->GetAllMarkedRect();
+ Invalidate( SID_RULER_OBJECT );
+ }
+ break;
+ }
+
+ case SID_ATTR_TABSTOP:
+ {
+ if( mpDrawView->IsTextEdit() )
+ {
+ const SvxTabStopItem& rItem = (const SvxTabStopItem&)
+ pArgs->Get( EE_PARA_TABS );
+
+ SfxItemSet aEditAttr( GetPool(), EE_PARA_TABS, EE_PARA_TABS );
+
+ aEditAttr.Put( rItem );
+ mpDrawView->SetAttributes( aEditAttr );
+
+ // #91081# Invalidate is missing here
+ Invalidate(SID_ATTR_TABSTOP);
+ }
+ break;
+ }
+
+ case SID_ATTR_PARA_LRSPACE:
+ {
+ if( mpDrawView->IsTextEdit() )
+ {
+ sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
+ const SvxLRSpaceItem& rItem = (const SvxLRSpaceItem&)
+ pArgs->Get( nId );
+
+ SfxItemSet aEditAttr( GetPool(), EE_PARA_LRSPACE, EE_PARA_LRSPACE );
+
+ nId = EE_PARA_LRSPACE;
+ SvxLRSpaceItem aLRSpaceItem( rItem.GetLeft(),
+ rItem.GetRight(), rItem.GetTxtLeft(),
+ rItem.GetTxtFirstLineOfst(), nId );
+ aEditAttr.Put( aLRSpaceItem );
+ mpDrawView->SetAttributes( aEditAttr );
+
+ // #92557# Invalidate is missing here
+ Invalidate(SID_ATTR_PARA_LRSPACE);
+ }
+ break;
+ }
+ }
+ if ( pUndoGroup )
+ // Undo Gruppe dem Undo Manager uebergeben
+ GetViewFrame()->GetObjectShell()->GetUndoManager()->
+ AddUndoAction(pUndoGroup);
+}
+
+/*************************************************************************
+|*
+|* Statuswerte der Lineale bestimmen
+|*
+\************************************************************************/
+void DrawViewShell::GetRulerState(SfxItemSet& rSet)
+{
+ Point aOrigin;
+
+ if (mpDrawView->GetSdrPageView())
+ {
+ aOrigin = mpDrawView->GetSdrPageView()->GetPageOrigin();
+ }
+
+ Size aViewSize = GetActiveWindow()->GetViewSize();
+
+ const Point aPagePos( GetActiveWindow()->GetViewOrigin() );
+ Size aPageSize = mpActualPage->GetSize();
+
+ Rectangle aRect(aPagePos, Point( aViewSize.Width() - (aPagePos.X() + aPageSize.Width()),
+ aViewSize.Height() - (aPagePos.Y() + aPageSize.Height())));
+
+ if( mpDrawView->IsTextEdit() )
+ {
+ Point aPnt1 = GetActiveWindow()->GetWinViewPos();
+ Point aPnt2 = GetActiveWindow()->GetViewOrigin();
+ Rectangle aMinMaxRect = Rectangle( aPnt1, Size(ULONG_MAX, ULONG_MAX) );
+ rSet.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX, aMinMaxRect) );
+ }
+ else
+ {
+ rSet.Put( SfxRectangleItem(SID_RULER_LR_MIN_MAX, aRect) );
+ }
+
+ SvxLongLRSpaceItem aLRSpace(aPagePos.X() + mpActualPage->GetLftBorder(),
+ aRect.Right() + mpActualPage->GetRgtBorder(),
+ GetPool().GetWhich(SID_ATTR_LONG_LRSPACE));
+ SvxLongULSpaceItem aULSpace(aPagePos.Y() + mpActualPage->GetUppBorder(),
+ aRect.Bottom() + mpActualPage->GetLwrBorder(),
+ GetPool().GetWhich(SID_ATTR_LONG_ULSPACE));
+ rSet.Put(SvxPagePosSizeItem(Point(0,0) - aPagePos, aViewSize.Width(),
+ aViewSize.Height()));
+ SfxPointItem aPointItem( SID_RULER_NULL_OFFSET, aPagePos + aOrigin );
+
+ SvxProtectItem aProtect( SID_RULER_PROTECT );
+
+ maMarkRect = mpDrawView->GetAllMarkedRect();
+
+ const sal_Bool bRTL = GetDoc() && GetDoc()->GetDefaultWritingMode() == ::com::sun::star::text::WritingMode_RL_TB;
+ rSet.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT, bRTL));
+
+ if( mpDrawView->AreObjectsMarked() )
+ {
+ if( mpDrawView->IsTextEdit() )
+ {
+ SdrObject* pObj = mpDrawView->GetMarkedObjectList().GetMark( 0 )->GetMarkedSdrObj();
+ if( pObj->GetObjInventor() == SdrInventor)
+ {
+ SfxItemSet aEditAttr( GetDoc()->GetPool() );
+ mpDrawView->GetAttributes( aEditAttr );
+ if( aEditAttr.GetItemState( EE_PARA_TABS ) >= SFX_ITEM_AVAILABLE )
+ {
+ const SvxTabStopItem& rItem = (const SvxTabStopItem&) aEditAttr.Get( EE_PARA_TABS );
+ rSet.Put( rItem );
+
+ //Rectangle aRect = maMarkRect;
+
+ const SvxLRSpaceItem& rLRSpaceItem = (const SvxLRSpaceItem&) aEditAttr.Get( EE_PARA_LRSPACE );
+ sal_uInt16 nId = SID_ATTR_PARA_LRSPACE;
+ SvxLRSpaceItem aLRSpaceItem( rLRSpaceItem.GetLeft(),
+ rLRSpaceItem.GetRight(), rLRSpaceItem.GetTxtLeft(),
+ rLRSpaceItem.GetTxtFirstLineOfst(), nId );
+ rSet.Put( aLRSpaceItem );
+
+ Point aPos( aPagePos + maMarkRect.TopLeft() );
+
+ if ( aEditAttr.GetItemState( SDRATTR_TEXT_LEFTDIST ) == SFX_ITEM_ON )
+ {
+ const SdrTextLeftDistItem& rTLDItem = (const SdrTextLeftDistItem&)
+ aEditAttr.Get( SDRATTR_TEXT_LEFTDIST );
+ long nLD = rTLDItem.GetValue();
+ aPos.X() += nLD;
+ }
+
+ aPointItem.SetValue( aPos );
+
+ aLRSpace.SetLeft( aPagePos.X() + maMarkRect.Left() );
+
+ if ( aEditAttr.GetItemState( SDRATTR_TEXT_LEFTDIST ) == SFX_ITEM_ON )
+ {
+ const SdrTextLeftDistItem& rTLDItem = (const SdrTextLeftDistItem&)
+ aEditAttr.Get( SDRATTR_TEXT_LEFTDIST );
+ long nLD = rTLDItem.GetValue();
+ aLRSpace.SetLeft( aLRSpace.GetLeft() + nLD );
+ }
+
+ aLRSpace.SetRight( aRect.Right() + aPageSize.Width() - maMarkRect.Right() );
+ aULSpace.SetUpper( aPagePos.Y() + maMarkRect.Top() );
+ aULSpace.SetLower( aRect.Bottom() + aPageSize.Height() - maMarkRect.Bottom() );
+
+ rSet.DisableItem( SID_RULER_OBJECT );
+
+ // Seitenraender werden gelocked
+ aProtect.SetSizeProtect( sal_True );
+ aProtect.SetPosProtect( sal_True );
+ }
+
+ if( aEditAttr.GetItemState( EE_PARA_WRITINGDIR ) >= SFX_ITEM_AVAILABLE )
+ {
+ const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&) aEditAttr.Get( EE_PARA_WRITINGDIR );
+ rSet.Put(SfxBoolItem(SID_RULER_TEXT_RIGHT_TO_LEFT, rItem.GetValue() == ::com::sun::star::text::WritingMode_RL_TB));
+ }
+ }
+ }
+ else
+ {
+ rSet.DisableItem( EE_PARA_TABS );
+ rSet.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT );
+
+ if( mpDrawView->IsResizeAllowed(sal_True) )
+ {
+ Rectangle aResizeRect( maMarkRect );
+
+ aResizeRect.SetPos(aResizeRect.TopLeft() + aPagePos);
+ SvxObjectItem aObjItem(aResizeRect.Left(), aResizeRect.Right(),
+ aResizeRect.Top(), aResizeRect.Bottom());
+ rSet.Put(aObjItem);
+ rSet.DisableItem( EE_PARA_TABS );
+ }
+ else
+ {
+ rSet.DisableItem( SID_RULER_OBJECT );
+ }
+ }
+ }
+ else
+ {
+ rSet.DisableItem( SID_RULER_OBJECT );
+ rSet.DisableItem( EE_PARA_TABS );
+// rSet.DisableItem( SID_RULER_TEXT_RIGHT_TO_LEFT );
+ }
+
+ rSet.Put( aLRSpace );
+ rSet.Put( aULSpace );
+
+ rSet.Put( aPointItem );
+ rSet.Put( aProtect );
+}
+
+/*************************************************************************
+|*
+|* SfxRequests fuer StatusBar bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecStatusBar(SfxRequest& rReq)
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if(HasCurrentFunction(SID_PRESENTATION))
+ return;
+
+ CheckLineTo (rReq);
+
+ switch ( rReq.GetSlot() )
+ {
+ case SID_ATTR_SIZE:
+ {
+ GetViewFrame()->GetDispatcher()->Execute( SID_ATTR_TRANSFORM, SFX_CALLMODE_ASYNCHRON );
+ }
+ break;
+
+ case SID_STATUS_LAYOUT:
+ {
+ GetViewFrame()->GetDispatcher()->Execute( SID_PRESENTATION_LAYOUT, SFX_CALLMODE_ASYNCHRON );
+ }
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* Status der Snap-Objekt-Eintraege im Popup setzen
+|*
+\************************************************************************/
+
+void DrawViewShell::GetSnapItemState( SfxItemSet &rSet )
+{
+ SdrPageView* pPV;
+ Point aMPos = GetActiveWindow()->PixelToLogic(maMousePos);
+ sal_uInt16 nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic(
+ Size(FuPoor::HITPIX,0)).Width();
+ sal_uInt16 nHelpLine;
+
+ if ( mpDrawView->PickHelpLine(aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
+ {
+ const SdrHelpLine& rHelpLine = (pPV->GetHelpLines())[nHelpLine];
+
+ if ( rHelpLine.GetKind() == SDRHELPLINE_POINT )
+ {
+ rSet.Put( SfxStringItem( SID_SET_SNAPITEM,
+ String( SdResId( STR_POPUP_EDIT_SNAPPOINT))) );
+ rSet.Put( SfxStringItem( SID_DELETE_SNAPITEM,
+ String( SdResId( STR_POPUP_DELETE_SNAPPOINT))) );
+ }
+ else
+ {
+ rSet.Put( SfxStringItem( SID_SET_SNAPITEM,
+ String( SdResId( STR_POPUP_EDIT_SNAPLINE))) );
+ rSet.Put( SfxStringItem( SID_DELETE_SNAPITEM,
+ String( SdResId( STR_POPUP_DELETE_SNAPLINE))) );
+ }
+ }
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void DrawViewShell::AddWindow (::sd::Window* pWin)
+{
+ mpDrawView->AddWindowToPaintView(pWin);
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void DrawViewShell::RemoveWindow(::sd::Window* pWin)
+{
+ mpDrawView->DeleteWindowFromPaintView(pWin);
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx
new file mode 100755
index 000000000000..0a369bbf7c1f
--- /dev/null
+++ b/sd/source/ui/view/drviews4.cxx
@@ -0,0 +1,1007 @@
+/*************************************************************************
+ *
+ * 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 <com/sun/star/drawing/XDrawPagesSupplier.hpp>
+
+#include "DrawViewShell.hxx"
+#include <vcl/msgbox.hxx>
+#include <svl/urlbmk.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/fmglob.hxx>
+#include <editeng/eeitem.hxx>
+#ifndef _FLDITEM_HXX
+#include <editeng/flditem.hxx>
+#endif
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svx/ruler.hxx>
+#ifndef _GLOBL3D_HXX
+#include <svx/globl3d.hxx>
+#endif
+#include <editeng/outliner.hxx>
+#ifndef _SFX_CLIENTSH_HXX
+#include <sfx2/ipclient.hxx>
+#endif
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdopath.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <editeng/editview.hxx>
+#include <vcl/cursor.hxx>
+
+
+#include "app.hrc"
+#include "glob.hrc"
+#include "strings.hrc"
+#include "res_bmp.hrc"
+#include "DrawDocShell.hxx"
+#include "drawdoc.hxx"
+#include "Window.hxx"
+#include "fupoor.hxx"
+#include "fusnapln.hxx"
+#include "app.hxx"
+#include "Ruler.hxx"
+#include "sdresid.hxx"
+#include "GraphicViewShell.hxx"
+#include "sdpage.hxx"
+#include "slideshow.hxx"
+#include "anminfo.hxx"
+#include "sdpopup.hxx"
+#include "drawview.hxx"
+#include <svx/bmpmask.hxx>
+#include "LayerTabBar.hxx"
+
+// #97016# IV
+#include <svx/svditer.hxx>
+
+namespace sd {
+
+#define PIPETTE_RANGE 0
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::drawing;
+
+/*************************************************************************
+|*
+|* aktuelle Seite loeschen
+|*
+\************************************************************************/
+
+void DrawViewShell::DeleteActualPage()
+{
+ sal_uInt16 nPage = maTabControl.GetCurPageId() - 1;
+
+ mpDrawView->SdrEndTextEdit();
+
+ try
+ {
+ Reference<XDrawPagesSupplier> xDrawPagesSupplier( GetDoc()->getUnoModel(), UNO_QUERY_THROW );
+ Reference<XDrawPages> xPages( xDrawPagesSupplier->getDrawPages(), UNO_QUERY_THROW );
+ Reference< XDrawPage > xPage( xPages->getByIndex( nPage ), UNO_QUERY_THROW );
+ xPages->remove( xPage );
+ }
+ catch( Exception& )
+ {
+ DBG_ERROR("SelectionManager::DeleteSelectedMasterPages(), exception caught!");
+ }
+}
+
+/*************************************************************************
+|*
+|* aktuelle Ebene loeschen
+|*
+\************************************************************************/
+
+void DrawViewShell::DeleteActualLayer()
+{
+ SdrLayerAdmin& rAdmin = GetDoc()->GetLayerAdmin();
+ const String& rName = GetLayerTabControl()->GetPageText(GetLayerTabControl()->GetCurPageId());
+ String aString(SdResId(STR_ASK_DELETE_LAYER));
+
+ // Platzhalter ersetzen
+ sal_uInt16 nPos = aString.Search(sal_Unicode('$'));
+ aString.Erase(nPos, 1);
+ aString.Insert(rName, nPos);
+
+ if (QueryBox(GetActiveWindow(), WB_YES_NO, aString).Execute() == RET_YES)
+ {
+ const SdrLayer* pLayer = rAdmin.GetLayer(rName, sal_False);
+ mpDrawView->DeleteLayer( pLayer->GetName() );
+
+ // damit TabBar und Window neu gezeichnet werden;
+ // sollte spaeter wie beim Aendern der Layerfolge durch einen
+ // Hint von Joe angestossen werden
+ // ( View::Notify() --> ViewShell::ResetActualLayer() )
+
+ mbIsLayerModeActive = false; // damit ChangeEditMode() ueberhaupt was tut
+ ChangeEditMode(GetEditMode(), true);
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Keyboard event
+|*
+\************************************************************************/
+
+sal_Bool DrawViewShell::KeyInput (const KeyEvent& rKEvt, ::sd::Window* pWin)
+{
+ sal_Bool bRet = sal_False;
+
+ if ( !IsInputLocked() || ( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) )
+ {
+ // #97016# IV
+ if(KEY_RETURN == rKEvt.GetKeyCode().GetCode()
+ && rKEvt.GetKeyCode().IsMod1()
+ && GetView()->IsTextEdit())
+ {
+ // this should be used for cursor travelling.
+ SdPage* pActualPage = GetActualPage();
+ const SdrMarkList& rMarkList = GetView()->GetMarkedObjectList();
+ SdrTextObj* pCandidate = 0L;
+
+ if(pActualPage && 1 == rMarkList.GetMarkCount())
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+
+ // remember which object was the text in edit mode
+ SdrObject* pOldObj = pMark->GetMarkedSdrObj();
+
+ // end text edit now
+ GetView()->SdrEndTextEdit();
+
+ // look for a new candidate, a successor of pOldObj
+ SdrObjListIter aIter(*pActualPage, IM_DEEPNOGROUPS);
+ sal_Bool bDidVisitOldObject(sal_False);
+
+ while(aIter.IsMore() && !pCandidate)
+ {
+ SdrObject* pObj = aIter.Next();
+
+ if(pObj && pObj->ISA(SdrTextObj))
+ {
+ sal_uInt32 nInv(pObj->GetObjInventor());
+ sal_uInt16 nKnd(pObj->GetObjIdentifier());
+
+ if(SdrInventor == nInv &&
+ (OBJ_TITLETEXT == nKnd || OBJ_OUTLINETEXT == nKnd || OBJ_TEXT == nKnd)
+ && bDidVisitOldObject)
+ {
+ pCandidate = (SdrTextObj*)pObj;
+ }
+
+ if(pObj == pOldObj)
+ {
+ bDidVisitOldObject = sal_True;
+ }
+ }
+ }
+ }
+
+ if(pCandidate)
+ {
+ // set the new candidate to text edit mode
+ GetView()->UnMarkAll();
+ GetView()->MarkObj(pCandidate, GetView()->GetSdrPageView());
+
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_ATTR_CHAR, SFX_CALLMODE_ASYNCHRON);
+ }
+ else
+ {
+ // insert a new page with the same page layout
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_INSERTPAGE_QUICK, SFX_CALLMODE_ASYNCHRON);
+ }
+ }
+ else
+ {
+ bRet = ViewShell::KeyInput(rKEvt, pWin);
+ }
+ }
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|* Vom Lineal ausgehenden Drag (Hilflinien, Ursprung) beginnen
+|*
+\************************************************************************/
+
+void DrawViewShell::StartRulerDrag (
+ const Ruler& rRuler,
+ const MouseEvent& rMEvt)
+{
+ GetActiveWindow()->CaptureMouse();
+
+ Point aWPos = GetActiveWindow()->PixelToLogic(GetActiveWindow()->GetPointerPosPixel());
+
+ if ( rRuler.GetExtraRect().IsInside(rMEvt.GetPosPixel()) )
+ {
+ mpDrawView->BegSetPageOrg(aWPos);
+ mbIsRulerDrag = sal_True;
+ }
+ else
+ {
+ // #i34536# if no guide-lines are visible yet, that show them
+ if( ! mpDrawView->IsHlplVisible())
+ mpDrawView->SetHlplVisible( sal_True );
+
+ SdrHelpLineKind eKind;
+
+ if ( rMEvt.IsMod1() )
+ eKind = SDRHELPLINE_POINT;
+ else if ( rRuler.IsHorizontal() )
+ eKind = SDRHELPLINE_HORIZONTAL;
+ else
+ eKind = SDRHELPLINE_VERTICAL;
+
+ mpDrawView->BegDragHelpLine(aWPos, eKind);
+ mbIsRulerDrag = sal_True;
+ }
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown event
+|*
+\************************************************************************/
+
+void DrawViewShell::MouseButtonDown(const MouseEvent& rMEvt,
+ ::sd::Window* pWin)
+{
+ // We have to check if a context menu is shown and we have an UI
+ // active inplace client. In that case we have to ignore the mouse
+ // button down event. Otherwise we would crash (context menu has been
+ // opened by inplace client and we would deactivate the inplace client,
+ // the contex menu is closed by VCL asynchronously which in the end
+ // would work on deleted objects or the context menu has no parent anymore)
+ // See #126086# and #128122#
+ SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
+ sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
+
+ if ( bIsOleActive && PopupMenu::IsInExecute() )
+ return;
+
+ if ( !IsInputLocked() )
+ {
+ ViewShell::MouseButtonDown(rMEvt, pWin);
+
+ if ( mbPipette )
+ ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->PipetteClicked();
+ }
+}
+
+/*************************************************************************
+|*
+|* MouseMove event
+|*
+\************************************************************************/
+
+
+void DrawViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
+{
+ if ( !IsInputLocked() )
+ {
+ if ( mpDrawView->IsAction() )
+ {
+ Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
+
+ if ( !aOutputArea.IsInside(rMEvt.GetPosPixel()) )
+ {
+ sal_Bool bInsideOtherWindow = sal_False;
+
+ if (mpContentWindow.get() != NULL)
+ {
+ aOutputArea = Rectangle(Point(0,0),
+ mpContentWindow->GetOutputSizePixel());
+
+ Point aPos = mpContentWindow->GetPointerPosPixel();
+ if ( aOutputArea.IsInside(aPos) )
+ bInsideOtherWindow = sal_True;
+ }
+
+ if (! GetActiveWindow()->HasFocus ())
+ {
+ GetActiveWindow()->ReleaseMouse ();
+ mpDrawView->BrkAction ();
+ return;
+ }
+ else if ( bInsideOtherWindow )
+ {
+ GetActiveWindow()->ReleaseMouse();
+ pWin->CaptureMouse ();
+ }
+ }
+ else if ( pWin != GetActiveWindow() )
+ pWin->CaptureMouse();
+ }
+
+ // #109585#
+ // Since the next MouseMove may execute a IsSolidDraggingNow() in
+ // SdrCreateView::MovCreateObj and there the ApplicationBackgroundColor
+ // is needed it is necessary to set it here.
+ if(mpDrawView!=NULL && GetDoc()!=NULL)
+ {
+ svtools::ColorConfig aColorConfig;
+ Color aFillColor;
+
+ if(DOCUMENT_TYPE_IMPRESS == GetDoc()->GetDocumentType())
+ {
+ aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor );
+ }
+ else
+ {
+ aFillColor = Color( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
+ }
+
+ mpDrawView->SetApplicationBackgroundColor(aFillColor);
+ }
+
+ ViewShell::MouseMove(rMEvt, pWin);
+
+ if( !mbMousePosFreezed )
+ maMousePos = rMEvt.GetPosPixel();
+
+ Rectangle aRect;
+
+ if ( mbIsRulerDrag )
+ {
+ Point aLogPos = GetActiveWindow()->PixelToLogic(maMousePos);
+ mpDrawView->MovAction(aLogPos);
+ }
+
+ if ( mpDrawView->IsAction() )
+ {
+ mpDrawView->TakeActionRect(aRect);
+ aRect = GetActiveWindow()->LogicToPixel(aRect);
+ }
+ else
+ {
+ aRect = Rectangle(maMousePos, maMousePos);
+ }
+
+ ShowMousePosInfo(aRect, pWin);
+
+ if ( mbPipette && GetViewFrame()->HasChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() ) )
+ {
+ const long nStartX = maMousePos.X() - PIPETTE_RANGE;
+ const long nEndX = maMousePos.X() + PIPETTE_RANGE;
+ const long nStartY = maMousePos.Y() - PIPETTE_RANGE;
+ const long nEndY = maMousePos.Y() + PIPETTE_RANGE;
+ long nRed = 0;
+ long nGreen = 0;
+ long nBlue = 0;
+ const double fDiv = ( ( PIPETTE_RANGE << 1 ) + 1 ) * ( ( PIPETTE_RANGE << 1 ) + 1 );
+
+ for ( long nY = nStartY; nY <= nEndY; nY++ )
+ {
+ for( long nX = nStartX; nX <= nEndX; nX++ )
+ {
+ const Color aCol( pWin->GetPixel( pWin->PixelToLogic( Point( nX, nY ) ) ) );
+
+ nRed += aCol.GetRed();
+ nGreen += aCol.GetGreen();
+ nBlue += aCol.GetBlue();
+ }
+ }
+
+ ( (SvxBmpMask*) GetViewFrame()->GetChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
+ SetColor( Color( (sal_uInt8) ( nRed / fDiv + .5 ),
+ (sal_uInt8) ( nGreen / fDiv + .5 ),
+ (sal_uInt8) ( nBlue / fDiv + .5 ) ) );
+ }
+ }
+}
+
+
+/*************************************************************************
+|*
+|* MouseButtonUp event
+|*
+\************************************************************************/
+
+void DrawViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
+{
+ if ( !IsInputLocked() )
+ {
+ FASTBOOL bIsSetPageOrg = mpDrawView->IsSetPageOrg();
+
+ if (mbIsRulerDrag)
+ {
+ Rectangle aOutputArea(Point(0,0), GetActiveWindow()->GetOutputSizePixel());
+
+ if (aOutputArea.IsInside(rMEvt.GetPosPixel()))
+ {
+ mpDrawView->EndAction();
+
+ if (bIsSetPageOrg)
+ GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
+ }
+ else if (rMEvt.IsLeft() && bIsSetPageOrg)
+ {
+ mpDrawView->BrkAction();
+ SdPage* pPage = (SdPage*) mpDrawView->GetSdrPageView()->GetPage();
+ Point aOrg(pPage->GetLftBorder(), pPage->GetUppBorder());
+ mpDrawView->GetSdrPageView()->SetPageOrigin(aOrg);
+ GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
+ }
+ else
+ {
+ mpDrawView->BrkAction();
+ }
+
+ GetActiveWindow()->ReleaseMouse();
+ mbIsRulerDrag = sal_False;
+ }
+ else
+ ViewShell::MouseButtonUp(rMEvt, pWin);
+ }
+}
+
+/*************************************************************************
+|*
+|* Command event
+|*
+\************************************************************************/
+
+void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
+{
+ // The command event is send to the window after a possible context
+ // menu from an inplace client is closed. Now we have the chance to
+ // deactivate the inplace client without any problem regarding parent
+ // windows and code on the stack.
+ // For more information, see #126086# and #128122#
+ SfxInPlaceClient* pIPClient = GetViewShell()->GetIPClient();
+ sal_Bool bIsOleActive = ( pIPClient && pIPClient->IsObjectInPlaceActive() );
+ if ( bIsOleActive && ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU ))
+ {
+ // Deactivate OLE object
+ mpDrawView->UnmarkAll();
+ SelectionHasChanged();
+ return;
+ }
+
+ if ( !IsInputLocked() )
+ {
+ if( GetView() &&GetView()->getSmartTags().Command(rCEvt) )
+ return;
+
+ const bool bNativeShow (SlideShow::IsRunning(GetViewShellBase()));
+
+ if( rCEvt.GetCommand() == COMMAND_PASTESELECTION && !bNativeShow )
+ {
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSelection( GetActiveWindow() ) );
+
+ if( aDataHelper.GetTransferable().is() )
+ {
+ Point aPos;
+ sal_Int8 nDnDAction = DND_ACTION_COPY;
+
+ if( GetActiveWindow() )
+ aPos = GetActiveWindow()->PixelToLogic( rCEvt.GetMousePosPixel() );
+
+ if( !mpDrawView->InsertData( aDataHelper, aPos, nDnDAction, sal_False ) )
+ {
+ INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
+
+ if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
+ ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
+ ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
+ {
+ InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
+ }
+ }
+ }
+ }
+ else if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bNativeShow &&
+ pWin != NULL && !mpDrawView->IsAction() && !SD_MOD()->GetWaterCan() )
+ {
+ sal_uInt16 nSdResId = 0; // ResourceID fuer Popup-Menue
+ sal_Bool bGraphicShell = this->ISA(GraphicViewShell);
+
+ // Ist ein Fangobjekt unter dem Mauszeiger?
+ SdrPageView* pPV;
+ Point aMPos = pWin->PixelToLogic( maMousePos );
+ sal_uInt16 nHitLog = (sal_uInt16) GetActiveWindow()->PixelToLogic(
+ Size(FuPoor::HITPIX, 0 ) ).Width();
+ sal_uInt16 nHelpLine;
+ // fuer Klebepunkt
+ SdrObject* pObj = NULL;
+ sal_uInt16 nPickId = 0;
+ // fuer Feldbefehl
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+ const SvxFieldItem* pFldItem = NULL;
+ if( pOLV )
+ pFldItem = pOLV->GetFieldAtSelection();
+ //pFldItem = pOLV->GetFieldUnderMousePointer();
+
+ // Hilfslinie
+ if ( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) )
+ {
+ nSdResId = RID_DRAW_SNAPOBJECT_POPUP;
+ ShowSnapLineContextMenu(*pPV, nHelpLine, rCEvt.GetMousePosPixel());
+ return;
+ }
+ // Klebepunkt unter dem Mauszeiger markiert?
+ else if( mpDrawView->PickGluePoint( aMPos, pObj, nPickId, pPV ) &&
+ mpDrawView->IsGluePointMarked( pObj, nPickId ) )
+ {
+ nSdResId = RID_DRAW_GLUEPOINT_POPUP;
+ }
+ // Feldbefehl ?
+ else if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
+ pFldItem->GetField()->ISA( SvxExtTimeField ) ||
+ pFldItem->GetField()->ISA( SvxExtFileField ) ||
+ pFldItem->GetField()->ISA( SvxAuthorField ) ) )
+ {
+ LanguageType eLanguage( LANGUAGE_SYSTEM );
+
+ // #101743# Format popup with outliner language, if possible
+ if( pOLV->GetOutliner() )
+ {
+ ESelection aSelection( pOLV->GetSelection() );
+ eLanguage = pOLV->GetOutliner()->GetLanguage( aSelection.nStartPara, aSelection.nStartPos );
+ }
+
+ SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage );
+
+ if ( rCEvt.IsMouseEvent() )
+ aMPos = rCEvt.GetMousePosPixel();
+ else
+ aMPos = Point( 20, 20 );
+ aFieldPopup.Execute( pWin, aMPos );
+
+ SvxFieldData* pField = aFieldPopup.GetField();
+ if( pField )
+ {
+ SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
+ //pOLV->DeleteSelected(); <-- fehlt leider !
+ // Feld selektieren, so dass es beim Insert geloescht wird
+ ESelection aSel = pOLV->GetSelection();
+ sal_Bool bSel = sal_True;
+ if( aSel.nStartPos == aSel.nEndPos )
+ {
+ bSel = sal_False;
+ aSel.nEndPos++;
+ }
+ pOLV->SetSelection( aSel );
+
+ pOLV->InsertField( aFieldItem );
+
+ // Selektion wird wieder in den Ursprungszustand gebracht
+ if( !bSel )
+ aSel.nEndPos--;
+ pOLV->SetSelection( aSel );
+
+ delete pField;
+ }
+ }
+ else
+ {
+ // ist etwas selektiert?
+ if (mpDrawView->AreObjectsMarked() &&
+ mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 )
+ {
+ pObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ if( HasCurrentFunction(SID_BEZIER_EDIT) && (dynamic_cast< SdrPathObj * >( pObj ) != 0 ) )
+ {
+ nSdResId = RID_BEZIER_POPUP;
+ }
+ else
+ {
+ if( mpDrawView->GetTextEditObject() )
+ {
+ OutlinerView* pOutlinerView = mpDrawView->GetTextEditOutlinerView();
+ Point aPos(rCEvt.GetMousePosPixel());
+
+ if ( pOutlinerView )
+ {
+ if( ( rCEvt.IsMouseEvent() && pOutlinerView->IsWrongSpelledWordAtPos(aPos) ) ||
+ ( !rCEvt.IsMouseEvent() && pOutlinerView->IsCursorAtWrongSpelledWord() ) )
+ {
+ // #91457# Popup for Online-Spelling now handled by DrawDocShell
+ // Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback);
+ Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
+
+ if( !rCEvt.IsMouseEvent() )
+ {
+ aPos = GetActiveWindow()->LogicToPixel( pOutlinerView->GetEditView().GetCursor()->GetPos() );
+ }
+ // While showing the spell context menu
+ // we lock the input so that another
+ // context menu can not be opened during
+ // that time (crash #i43235#). In order
+ // to not lock the UI completely we
+ // first release the mouse.
+ GetActiveWindow()->ReleaseMouse();
+ LockInput();
+ pOutlinerView->ExecuteSpellPopup(aPos, &aLink);
+ UnlockInput();
+ }
+ else
+ {
+ if( (pObj->GetObjInventor() == SdrInventor) && (pObj->GetObjIdentifier() == OBJ_TABLE) )
+ {
+ nSdResId = RID_DRAW_TABLEOBJ_INSIDE_POPUP;
+ }
+ else
+ {
+ nSdResId = RID_DRAW_TEXTOBJ_INSIDE_POPUP;
+ }
+ }
+ }
+ }
+ else
+ {
+ sal_uInt32 nInv = pObj->GetObjInventor();
+ sal_uInt16 nId = pObj->GetObjIdentifier();
+
+ if (nInv == SdrInventor)
+ {
+ switch ( nId )
+ {
+ case OBJ_CAPTION:
+ case OBJ_TITLETEXT:
+ case OBJ_OUTLINETEXT:
+ case OBJ_TEXT:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_TEXTOBJ_POPUP :
+ RID_DRAW_TEXTOBJ_POPUP;
+ break;
+
+ case OBJ_PATHLINE:
+ case OBJ_PLIN:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_POLYLINEOBJ_POPUP :
+ RID_DRAW_POLYLINEOBJ_POPUP;
+ break;
+
+ case OBJ_FREELINE:
+ case OBJ_EDGE: // Connector
+ nSdResId = bGraphicShell ? RID_GRAPHIC_EDGEOBJ_POPUP :
+ RID_DRAW_EDGEOBJ_POPUP;
+ break;
+
+ case OBJ_LINE:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_LINEOBJ_POPUP :
+ RID_DRAW_LINEOBJ_POPUP;
+ break;
+
+ case OBJ_MEASURE:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_MEASUREOBJ_POPUP :
+ RID_DRAW_MEASUREOBJ_POPUP;
+ break;
+
+ case OBJ_RECT:
+ case OBJ_CIRC:
+ case OBJ_FREEFILL:
+ case OBJ_PATHFILL:
+ case OBJ_POLY:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_GEOMOBJ_POPUP :
+ RID_DRAW_GEOMOBJ_POPUP;
+ break;
+
+ case OBJ_CUSTOMSHAPE:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_CUSTOMSHAPE_POPUP :
+ RID_DRAW_CUSTOMSHAPE_POPUP;
+ break;
+
+ case OBJ_GRUP:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_GROUPOBJ_POPUP :
+ RID_DRAW_GROUPOBJ_POPUP;
+ break;
+
+ case OBJ_GRAF:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_GRAPHIC_POPUP :
+ RID_DRAW_GRAPHIC_POPUP;
+ break;
+
+ case OBJ_OLE2:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_OLE2_POPUP :
+ RID_DRAW_OLE2_POPUP;
+ break;
+ case OBJ_MEDIA:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_MEDIA_POPUP :
+ RID_DRAW_MEDIA_POPUP;
+ break;
+ case OBJ_TABLE:
+ nSdResId = bGraphicShell ? RID_GRAPHIC_TABLE_POPUP :
+ RID_DRAW_TABLE_POPUP;
+ break;
+ }
+ }
+ else if( nInv == E3dInventor /*&& nId == E3D_POLYSCENE_ID*/)
+ {
+ if( nId == E3D_POLYSCENE_ID || nId == E3D_SCENE_ID )
+ {
+ if( !mpDrawView->IsGroupEntered() )
+ nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE_POPUP :
+ RID_DRAW_3DSCENE_POPUP;
+ else
+ nSdResId = bGraphicShell ? RID_GRAPHIC_3DSCENE2_POPUP :
+ RID_DRAW_3DSCENE2_POPUP;
+ }
+ else
+ nSdResId = bGraphicShell ? RID_GRAPHIC_3DOBJ_POPUP :
+ RID_DRAW_3DOBJ_POPUP;
+ }
+ else if( nInv == FmFormInventor )
+ {
+ nSdResId = RID_FORM_CONTROL_POPUP;
+ }
+ }
+ }
+ }
+
+ // Mehrfachselektion
+ else if (mpDrawView->AreObjectsMarked() &&
+ mpDrawView->GetMarkedObjectList().GetMarkCount() > 1 )
+ {
+ nSdResId = bGraphicShell ? RID_GRAPHIC_MULTISELECTION_POPUP :
+ RID_DRAW_MULTISELECTION_POPUP;
+ }
+
+ // nichts selektiert
+ else
+ {
+ nSdResId = bGraphicShell ? RID_GRAPHIC_NOSEL_POPUP :
+ RID_DRAW_NOSEL_POPUP;
+ }
+ }
+ // Popup-Menue anzeigen
+ if (nSdResId)
+ {
+ GetActiveWindow()->ReleaseMouse();
+
+ if(rCEvt.IsMouseEvent())
+ GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId));
+ else
+ {
+ //#106326# don't open contextmenu at mouse position if not opened via mouse
+
+ //middle of the window if nothing is marked
+ Point aMenuPos(GetActiveWindow()->GetSizePixel().Width()/2
+ ,GetActiveWindow()->GetSizePixel().Height()/2);
+
+ //middle of the bounding rect if something is marked
+ if( mpDrawView->AreObjectsMarked() && mpDrawView->GetMarkedObjectList().GetMarkCount() >= 1 )
+ {
+ Rectangle aMarkRect;
+ mpDrawView->GetMarkedObjectList().TakeBoundRect(NULL,aMarkRect);
+ aMenuPos = GetActiveWindow()->LogicToPixel( aMarkRect.Center() );
+
+ //move the point into the visible window area
+ if( aMenuPos.X() < 0 )
+ aMenuPos.X() = 0;
+ if( aMenuPos.Y() < 0 )
+ aMenuPos.Y() = 0;
+ if( aMenuPos.X() > GetActiveWindow()->GetSizePixel().Width() )
+ aMenuPos.X() = GetActiveWindow()->GetSizePixel().Width();
+ if( aMenuPos.Y() > GetActiveWindow()->GetSizePixel().Height() )
+ aMenuPos.Y() = GetActiveWindow()->GetSizePixel().Height();
+ }
+
+ //open context menu at that point
+ GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(nSdResId),GetActiveWindow(),&aMenuPos);
+ }
+ mbMousePosFreezed = sal_False;
+ }
+ }
+ else
+ {
+ ViewShell::Command(rCEvt, pWin);
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Linealmarkierungen anzeigen
+|*
+\************************************************************************/
+
+void DrawViewShell::ShowMousePosInfo(const Rectangle& rRect,
+ ::sd::Window* pWin)
+{
+ if (mbHasRulers && pWin )
+ {
+ RulerLine pHLines[2];
+ RulerLine pVLines[2];
+ long nHOffs = 0L;
+ long nVOffs = 0L;
+ sal_uInt16 nCnt;
+
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->SetLines();
+
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->SetLines();
+
+ if (mpHorizontalRuler.get() != NULL)
+ {
+ nHOffs = mpHorizontalRuler->GetNullOffset() +
+ mpHorizontalRuler->GetPageOffset();
+ }
+
+ if (mpVerticalRuler.get() != NULL)
+ {
+ nVOffs = mpVerticalRuler->GetNullOffset() +
+ mpVerticalRuler->GetPageOffset();
+ }
+
+ nCnt = 1;
+ pHLines[0].nPos = rRect.Left() - nHOffs;
+ pVLines[0].nPos = rRect.Top() - nVOffs;
+ pHLines[0].nStyle = 0;
+ pVLines[0].nStyle = 0;
+
+ if ( rRect.Right() != rRect.Left() || rRect.Bottom() != rRect.Top() )
+ {
+ pHLines[1].nPos = rRect.Right() - nHOffs;
+ pVLines[1].nPos = rRect.Bottom() - nVOffs;
+ pHLines[1].nStyle = 0;
+ pVLines[1].nStyle = 0;
+ nCnt++;
+ }
+
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->SetLines(nCnt, pHLines);
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->SetLines(nCnt, pVLines);
+ }
+
+ // StatusBar Koordinatenanzeige
+ OSL_ASSERT (GetViewShell()!=NULL);
+ if ( !GetViewShell()->GetUIActiveClient() )
+ {
+ SfxItemSet aSet(GetPool(), SID_CONTEXT, SID_CONTEXT,
+ SID_ATTR_POSITION, SID_ATTR_POSITION,
+ SID_ATTR_SIZE, SID_ATTR_SIZE,
+ 0L);
+
+// GetStatusBarState(aSet); nicht performant bei gedrueckter Modifiertaste!!
+
+ aSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.SetState(aSet);
+ rBindings.Invalidate(SID_CONTEXT);
+ rBindings.Invalidate(SID_ATTR_POSITION);
+ rBindings.Invalidate(SID_ATTR_SIZE);
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void DrawViewShell::LockInput()
+{
+ mnLockCount++;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void DrawViewShell::UnlockInput()
+{
+ DBG_ASSERT( mnLockCount, "Input for this shell is not locked!" );
+ if ( mnLockCount )
+ mnLockCount--;
+}
+
+
+
+
+void DrawViewShell::ShowSnapLineContextMenu (
+ SdrPageView& rPageView,
+ const sal_uInt16 nSnapLineIndex,
+ const Point& rMouseLocation)
+{
+ const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]);
+ ::boost::scoped_ptr<PopupMenu> pMenu (new PopupMenu ());
+
+ if (rHelpLine.GetKind() == SDRHELPLINE_POINT)
+ {
+ pMenu->InsertItem(
+ SID_SET_SNAPITEM,
+ String(SdResId(STR_POPUP_EDIT_SNAPPOINT)));
+ pMenu->InsertSeparator();
+ pMenu->InsertItem(
+ SID_DELETE_SNAPITEM,
+ String(SdResId(STR_POPUP_DELETE_SNAPPOINT)));
+ }
+ else
+ {
+ pMenu->InsertItem(
+ SID_SET_SNAPITEM,
+ String(SdResId(STR_POPUP_EDIT_SNAPLINE)));
+ pMenu->InsertSeparator();
+ pMenu->InsertItem(
+ SID_DELETE_SNAPITEM,
+ String(SdResId(STR_POPUP_DELETE_SNAPLINE)));
+ }
+
+ pMenu->RemoveDisabledEntries(sal_False, sal_False);
+
+ const sal_uInt16 nResult = pMenu->Execute(
+ GetActiveWindow(),
+ Rectangle(rMouseLocation, Size(10,10)),
+ POPUPMENU_EXECUTE_DOWN);
+ switch (nResult)
+ {
+ case SID_SET_SNAPITEM:
+ {
+ SfxUInt32Item aHelpLineItem (ID_VAL_INDEX, nSnapLineIndex);
+ const SfxPoolItem* aArguments[] = {&aHelpLineItem, NULL};
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_SET_SNAPITEM,
+ SFX_CALLMODE_SLOT,
+ aArguments);
+ }
+ break;
+
+ case SID_DELETE_SNAPITEM:
+ {
+ rPageView.DeleteHelpLine(nSnapLineIndex);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx
new file mode 100755
index 000000000000..e872435d604c
--- /dev/null
+++ b/sd/source/ui/view/drviews5.cxx
@@ -0,0 +1,746 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include "PresentationViewShell.hxx"
+#include <editeng/outliner.hxx>
+#ifndef _SVXIDS_HXX
+#include <svx/svxids.hrc>
+#endif
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdpagv.hxx>
+#include <vcl/scrbar.hxx>
+#include <tools/poly.hxx>
+#include <svx/fmshell.hxx>
+#include <editeng/eeitem.hxx>
+#include <svtools/colorcfg.hxx>
+#include "AccessibleDrawDocumentView.hxx"
+
+#include <sfx2/viewfrm.hxx>
+#include "LayerTabBar.hxx"
+
+#include "strings.hrc"
+#include "res_bmp.hrc"
+#include "glob.hrc"
+#include "app.hrc"
+#include "helpids.h"
+#include "optsitem.hxx"
+#include "app.hxx"
+#include "FrameView.hxx"
+#include "sdattr.hxx"
+#include "futext.hxx"
+#include "sdpage.hxx"
+#include "stlpool.hxx"
+#include "prntopts.hxx"
+#include "sdresid.hxx"
+#include "Window.hxx"
+#include "drawview.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "Outliner.hxx"
+#include "Client.hxx"
+#include "slideshow.hxx"
+#include "unokywds.hxx"
+#include "SdUnoDrawView.hxx"
+#include "ViewShellBase.hxx"
+#include "FormShellManager.hxx"
+#include "LayerDialogContent.hxx"
+#include "DrawController.hxx"
+
+namespace sd {
+
+static const int TABCONTROL_INITIAL_SIZE = 350;
+static const int PAPER_SHADOW_EXT_PIXEL = 2;
+
+
+/*************************************************************************
+|*
+|* Wird gerufen, wenn sich das Model aendert
+|*
+\************************************************************************/
+
+void DrawViewShell::ModelHasChanged()
+{
+ Invalidate();
+ // Damit der Navigator auch einen aktuellen Status bekommt
+ GetViewFrame()->GetBindings().Invalidate( SID_NAVIGATOR_STATE, sal_True, sal_False );
+
+ //Update3DWindow();
+ SfxBoolItem aItem( SID_3D_STATE, sal_True );
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_3D_STATE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+
+ // jetzt den von der Drawing Engine neu erzeugten TextEditOutliner
+ // initialisieren
+ ::Outliner* pOutliner = mpDrawView->GetTextEditOutliner();
+ if (pOutliner)
+ {
+ SfxStyleSheetPool* pSPool = (SfxStyleSheetPool*) GetDocSh()->GetStyleSheetPool();
+ pOutliner->SetStyleSheetPool(pSPool);
+ }
+}
+
+
+
+
+void DrawViewShell::Resize (void)
+{
+ ViewShell::Resize();
+
+ if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ {
+ SetZoomRect( GetDocSh()->GetVisArea(ASPECT_CONTENT) );
+ }
+
+ rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if( xSlideshow.is() && xSlideshow->isRunning() && !xSlideshow->isFullScreen() )
+ {
+ xSlideshow->resize(maViewSize);
+ }
+}
+
+
+
+
+void DrawViewShell::ArrangeGUIElements (void)
+{
+ // Retrieve the current size (thickness) of the scroll bars. That is
+ // the width of the vertical and the height of the horizontal scroll
+ // bar.
+ int nScrollBarSize =
+ GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize();
+ maScrBarWH = Size (nScrollBarSize, nScrollBarSize);
+
+ Point aHPos = maViewPos;
+ aHPos.Y() += maViewSize.Height();
+
+
+ ViewShell::ArrangeGUIElements ();
+
+ maTabControl.Hide();
+
+ OSL_ASSERT (GetViewShell()!=NULL);
+ Client* pIPClient = static_cast<Client*>(GetViewShell()->GetIPClient());
+ sal_Bool bClientActive = sal_False;
+ if ( pIPClient && pIPClient->IsObjectInPlaceActive() )
+ bClientActive = sal_True;
+
+ sal_Bool bInPlaceActive = GetViewFrame()->GetFrame().IsInPlace();
+
+ if ( mbZoomOnPage && !bInPlaceActive && !bClientActive )
+ {
+ // bei Split immer erstes Fenster resizen
+ //af pWindow = mpContentWindow.get();
+ SfxRequest aReq(SID_SIZE_PAGE, 0, GetDoc()->GetItemPool());
+ ExecuteSlot( aReq );
+ }
+}
+
+/*************************************************************************
+|*
+|* Daten der FrameView auf die aktuelle View uebertragen
+|*
+\************************************************************************/
+
+void DrawViewShell::ReadFrameViewData(FrameView* pView)
+{
+ ModifyGuard aGuard( GetDoc() );
+
+ // Diese Option wird am Model eingestellt
+ GetDoc()->SetPickThroughTransparentTextFrames(
+ SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType())->IsPickThrough());
+
+ // Initialisierungen der Zeichen-(Bildschirm-)Attribute
+ if (HasRuler() != pView->HasRuler())
+ SetRuler( pView->HasRuler() );
+
+ if (mpDrawView->GetGridCoarse() != pView->GetGridCoarse())
+ mpDrawView->SetGridCoarse( pView->GetGridCoarse() );
+
+ if (mpDrawView->GetGridFine() != pView->GetGridFine())
+ mpDrawView->SetGridFine( pView->GetGridFine() );
+
+ if (mpDrawView->GetSnapGridWidthX() != pView->GetSnapGridWidthX() || mpDrawView->GetSnapGridWidthY() != pView->GetSnapGridWidthY())
+ mpDrawView->SetSnapGridWidth(pView->GetSnapGridWidthX(), pView->GetSnapGridWidthY());
+
+ if (mpDrawView->IsGridVisible() != pView->IsGridVisible())
+ mpDrawView->SetGridVisible( pView->IsGridVisible() );
+
+ if (mpDrawView->IsGridFront() != pView->IsGridFront())
+ mpDrawView->SetGridFront( pView->IsGridFront() );
+
+ if (mpDrawView->GetSnapAngle() != pView->GetSnapAngle())
+ mpDrawView->SetSnapAngle( pView->GetSnapAngle() );
+
+ if (mpDrawView->IsGridSnap() != pView->IsGridSnap() )
+ mpDrawView->SetGridSnap( pView->IsGridSnap() );
+
+ if (mpDrawView->IsBordSnap() != pView->IsBordSnap() )
+ mpDrawView->SetBordSnap( pView->IsBordSnap() );
+
+ if (mpDrawView->IsHlplSnap() != pView->IsHlplSnap() )
+ mpDrawView->SetHlplSnap( pView->IsHlplSnap() );
+
+ if (mpDrawView->IsOFrmSnap() != pView->IsOFrmSnap() )
+ mpDrawView->SetOFrmSnap( pView->IsOFrmSnap() );
+
+ if (mpDrawView->IsOPntSnap() != pView->IsOPntSnap() )
+ mpDrawView->SetOPntSnap( pView->IsOPntSnap() );
+
+ if (mpDrawView->IsOConSnap() != pView->IsOConSnap() )
+ mpDrawView->SetOConSnap( pView->IsOConSnap() );
+
+ if (mpDrawView->IsHlplVisible() != pView->IsHlplVisible() )
+ mpDrawView->SetHlplVisible( pView->IsHlplVisible() );
+
+ if (mpDrawView->IsDragStripes() != pView->IsDragStripes() )
+ mpDrawView->SetDragStripes( pView->IsDragStripes() );
+
+ if (mpDrawView->IsPlusHandlesAlwaysVisible() != pView->IsPlusHandlesAlwaysVisible() )
+ mpDrawView->SetPlusHandlesAlwaysVisible( pView->IsPlusHandlesAlwaysVisible() );
+
+ if (mpDrawView->GetSnapMagneticPixel() != pView->GetSnapMagneticPixel() )
+ mpDrawView->SetSnapMagneticPixel( pView->GetSnapMagneticPixel() );
+
+ if (mpDrawView->IsMarkedHitMovesAlways() != pView->IsMarkedHitMovesAlways() )
+ mpDrawView->SetMarkedHitMovesAlways( pView->IsMarkedHitMovesAlways() );
+
+ if (mpDrawView->IsMoveOnlyDragging() != pView->IsMoveOnlyDragging() )
+ mpDrawView->SetMoveOnlyDragging( pView->IsMoveOnlyDragging() );
+
+// mpDrawView->SetSlantButShear( pView->IsSlantButShear() );
+
+ if (mpDrawView->IsNoDragXorPolys() != pView->IsNoDragXorPolys() )
+ mpDrawView->SetNoDragXorPolys( pView->IsNoDragXorPolys() );
+
+ if (mpDrawView->IsCrookNoContortion() != pView->IsCrookNoContortion() )
+ mpDrawView->SetCrookNoContortion( pView->IsCrookNoContortion() );
+
+ if (mpDrawView->IsAngleSnapEnabled() != pView->IsAngleSnapEnabled() )
+ mpDrawView->SetAngleSnapEnabled( pView->IsAngleSnapEnabled() );
+
+ if (mpDrawView->IsBigOrtho() != pView->IsBigOrtho() )
+ mpDrawView->SetBigOrtho( pView->IsBigOrtho() );
+
+ if (mpDrawView->IsOrtho() != pView->IsOrtho() )
+ mpDrawView->SetOrtho( pView->IsOrtho() );
+
+ if (mpDrawView->GetEliminatePolyPointLimitAngle() != pView->GetEliminatePolyPointLimitAngle() )
+ mpDrawView->SetEliminatePolyPointLimitAngle( pView->GetEliminatePolyPointLimitAngle() );
+
+ if (mpDrawView->IsEliminatePolyPoints() != pView->IsEliminatePolyPoints() )
+ mpDrawView->SetEliminatePolyPoints( pView->IsEliminatePolyPoints() );
+
+ if (mpDrawView->IsSolidMarkHdl() != pView->IsSolidMarkHdl() )
+ mpDrawView->SetSolidMarkHdl( pView->IsSolidMarkHdl() );
+
+ if (mpDrawView->IsSolidDragging() != pView->IsSolidDragging() )
+ mpDrawView->SetSolidDragging( pView->IsSolidDragging() );
+
+ if (mpDrawView->IsQuickTextEditMode() != pView->IsQuickEdit())
+ mpDrawView->SetQuickTextEditMode( pView->IsQuickEdit() );
+
+ // #i26631#
+ if (mpDrawView->IsMasterPagePaintCaching() != pView->IsMasterPagePaintCaching())
+ mpDrawView->SetMasterPagePaintCaching( pView->IsMasterPagePaintCaching() );
+
+ // Definition:
+ // grosse Handles: 9
+ // kleine Handles: 7
+ sal_uInt16 nTmp = mpDrawView->GetMarkHdlSizePixel();
+ //DBG_ASSERT(nTmp != 7, "HandleSize != 7 oder 9");
+ if( nTmp == 9 && !pView->IsBigHandles() )
+ mpDrawView->SetMarkHdlSizePixel( 7 );
+ else if( nTmp == 7 && pView->IsBigHandles() )
+ mpDrawView->SetMarkHdlSizePixel( 9 );
+
+
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+ if (pPageView)
+ {
+ if ( pPageView->GetVisibleLayers() != pView->GetVisibleLayers() )
+ pPageView->SetVisibleLayers( pView->GetVisibleLayers() );
+
+ if ( pPageView->GetPrintableLayers() != pView->GetPrintableLayers() )
+ pPageView->SetPrintableLayers( pView->GetPrintableLayers() );
+
+ if ( pPageView->GetLockedLayers() != pView->GetLockedLayers() )
+ pPageView->SetLockedLayers( pView->GetLockedLayers() );
+
+ if (mePageKind == PK_NOTES)
+ {
+ if (pPageView->GetHelpLines() != pView->GetNotesHelpLines())
+ pPageView->SetHelpLines( pView->GetNotesHelpLines() );
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ if (pPageView->GetHelpLines() != pView->GetHandoutHelpLines())
+ pPageView->SetHelpLines( pView->GetHandoutHelpLines() );
+ }
+ else
+ {
+ if (pPageView->GetHelpLines() != pView->GetStandardHelpLines())
+ pPageView->SetHelpLines( pView->GetStandardHelpLines() );
+ }
+ }
+
+ if ( mpDrawView->GetActiveLayer() != pView->GetActiveLayer() )
+ mpDrawView->SetActiveLayer( pView->GetActiveLayer() );
+
+ sal_uInt16 nSelectedPage = 0;
+
+ if (mePageKind != PK_HANDOUT)
+ {
+ nSelectedPage = pView->GetSelectedPage();
+ }
+
+ EditMode eNewEditMode = pView->GetViewShEditMode(mePageKind);
+ sal_Bool bNewLayerMode = pView->IsLayerMode();
+ ChangeEditMode(eNewEditMode, bNewLayerMode);
+ SwitchPage(nSelectedPage);
+
+ // DrawMode fuer 'Normales' Fenster wiederherstellen
+ if(GetActiveWindow()->GetDrawMode() != pView->GetDrawMode())
+ GetActiveWindow()->SetDrawMode(pView->GetDrawMode());
+
+ if ( mpDrawView->IsDesignMode() != pView->IsDesignMode() )
+ {
+ SfxBoolItem aDesignModeItem( SID_FM_DESIGN_MODE, pView->IsDesignMode() );
+ GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aDesignModeItem, 0L );
+ }
+
+ // Muss am Ende gerufen werden, da ein WriteFrameViewData() ausgeloest wird
+ if (mpDrawView->IsFrameDragSingles() != pView->IsFrameDragSingles() )
+ mpDrawView->SetFrameDragSingles( pView->IsFrameDragSingles() );
+}
+
+/*************************************************************************
+|*
+|* Daten der aktuellen View auf die FrameView uebertragen
+|*
+\************************************************************************/
+
+void DrawViewShell::WriteFrameViewData()
+{
+ // Zeichen-(Bildschirm-)Attribute an FrameView merken
+ mpFrameView->SetRuler( HasRuler() );
+ mpFrameView->SetGridCoarse( mpDrawView->GetGridCoarse() );
+ mpFrameView->SetGridFine( mpDrawView->GetGridFine() );
+ mpFrameView->SetSnapGridWidth(mpDrawView->GetSnapGridWidthX(), mpDrawView->GetSnapGridWidthY());
+ mpFrameView->SetGridVisible( mpDrawView->IsGridVisible() );
+ mpFrameView->SetGridFront( mpDrawView->IsGridFront() );
+ mpFrameView->SetSnapAngle( mpDrawView->GetSnapAngle() );
+ mpFrameView->SetGridSnap( mpDrawView->IsGridSnap() );
+ mpFrameView->SetBordSnap( mpDrawView->IsBordSnap() );
+ mpFrameView->SetHlplSnap( mpDrawView->IsHlplSnap() );
+ mpFrameView->SetOFrmSnap( mpDrawView->IsOFrmSnap() );
+ mpFrameView->SetOPntSnap( mpDrawView->IsOPntSnap() );
+ mpFrameView->SetOConSnap( mpDrawView->IsOConSnap() );
+ mpFrameView->SetHlplVisible( mpDrawView->IsHlplVisible() );
+ mpFrameView->SetDragStripes( mpDrawView->IsDragStripes() );
+ mpFrameView->SetPlusHandlesAlwaysVisible( mpDrawView->IsPlusHandlesAlwaysVisible() );
+ mpFrameView->SetFrameDragSingles( mpDrawView->IsFrameDragSingles() );
+ mpFrameView->SetMarkedHitMovesAlways( mpDrawView->IsMarkedHitMovesAlways() );
+ mpFrameView->SetMoveOnlyDragging( mpDrawView->IsMoveOnlyDragging() );
+ mpFrameView->SetNoDragXorPolys( mpDrawView->IsNoDragXorPolys() );
+ mpFrameView->SetCrookNoContortion( mpDrawView->IsCrookNoContortion() );
+ mpFrameView->SetBigOrtho( mpDrawView->IsBigOrtho() );
+ mpFrameView->SetEliminatePolyPointLimitAngle( mpDrawView->GetEliminatePolyPointLimitAngle() );
+ mpFrameView->SetEliminatePolyPoints( mpDrawView->IsEliminatePolyPoints() );
+
+ mpFrameView->SetSolidMarkHdl( mpDrawView->IsSolidMarkHdl() );
+ mpFrameView->SetSolidDragging( mpDrawView->IsSolidDragging() );
+ mpFrameView->SetQuickEdit( mpDrawView->IsQuickTextEditMode() );
+
+ mpFrameView->SetDesignMode( mpDrawView->IsDesignMode() );
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisArea = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ mpFrameView->SetVisArea(aVisArea);
+
+ if( mePageKind == PK_HANDOUT )
+ mpFrameView->SetSelectedPage(0);
+ else
+ {
+ mpFrameView->SetSelectedPage( maTabControl.GetCurPageId() - 1 );
+ }
+
+ mpFrameView->SetViewShEditMode(meEditMode, mePageKind);
+ mpFrameView->SetLayerMode(IsLayerModeActive());
+
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+
+ if (pPageView)
+ {
+ if ( mpFrameView->GetVisibleLayers() != pPageView->GetVisibleLayers() )
+ mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
+
+ if ( mpFrameView->GetPrintableLayers() != pPageView->GetPrintableLayers() )
+ mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
+
+ if ( mpFrameView->GetLockedLayers() != pPageView->GetLockedLayers() )
+ mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
+
+ if (mePageKind == PK_NOTES)
+ {
+ mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
+ }
+ else
+ {
+ mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
+ }
+ }
+
+ if ( mpFrameView->GetActiveLayer() != mpDrawView->GetActiveLayer() )
+ mpFrameView->SetActiveLayer( mpDrawView->GetActiveLayer() );
+
+ // DrawMode fuer 'Normales' Fenster merken
+ if(mpFrameView->GetDrawMode() != GetActiveWindow()->GetDrawMode())
+ mpFrameView->SetDrawMode(GetActiveWindow()->GetDrawMode());
+}
+
+
+
+/*************************************************************************
+|*
+|* PrePaint-Method
+|*
+\************************************************************************/
+
+void DrawViewShell::PrePaint()
+{
+ mpDrawView->PrePaint();
+}
+
+/*************************************************************************
+|*
+|* Paint-Methode: das Ereignis wird vom Fenster pWin an
+|* die Viewshell und die aktuelle Funktion weitergeleitet
+|*
+|* Anmerkung: pWin==NULL, wenn Paint() vom ShowWindow gerufen wird!
+|*
+\************************************************************************/
+
+void DrawViewShell::Paint(const Rectangle& rRect, ::sd::Window* pWin)
+{
+ // #103834# Fill var FillColor here to have it available on later call
+ svtools::ColorConfig aColorConfig;
+ Color aFillColor;
+
+ if(DOCUMENT_TYPE_IMPRESS == GetDoc()->GetDocumentType())
+ {
+ aFillColor = Color( aColorConfig.GetColorValue( svtools::APPBACKGROUND ).nColor );
+ }
+ else
+ {
+ aFillColor = Color( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
+ }
+
+ /* #97517# This is done before each text edit, so why not do it before every paint.
+ The default language is only used if the outliner only contains one
+ character in a symbol font */
+ GetDoc()->GetDrawOutliner( NULL ).SetDefaultLanguage( GetDoc()->GetLanguage( EE_CHAR_LANGUAGE ) );
+
+ // #103834# Set Application Background color for usage in SdrPaintView(s)
+ mpDrawView->SetApplicationBackgroundColor(aFillColor);
+
+ /* #97517# This is done before each text edit, so why not do it before every paint.
+ The default language is only used if the outliner only contains one
+ character in a symbol font */
+ GetDoc()->GetDrawOutliner( NULL ).SetDefaultLanguage( Application::GetSettings().GetLanguage() );
+
+ mpDrawView->CompleteRedraw( pWin, Region( rRect ) );
+
+ if( pWin )
+ {
+ if( GetDocSh()->GetDocShellFunction().is() )
+ GetDocSh()->GetDocShellFunction()->Paint( rRect, pWin );
+
+ if( HasCurrentFunction() )
+ GetCurrentFunction()->Paint( rRect, pWin );
+ }
+}
+
+/*************************************************************************
+|*
+|* Zoom-Faktor fuer InPlace einstellen
+|*
+\************************************************************************/
+
+void DrawViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction& rZoomY)
+{
+ ViewShell::SetZoomFactor(rZoomX, rZoomY);
+ mbZoomOnPage = sal_False;
+ Point aOrigin = GetActiveWindow()->GetViewOrigin();
+ GetActiveWindow()->SetWinViewPos(aOrigin);
+}
+
+/*************************************************************************
+|*
+|* Optimale Groesse zurueckgeben
+|*
+\************************************************************************/
+
+Size DrawViewShell::GetOptimalSizePixel() const
+{
+ Size aSize;
+
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+ if (pPV)
+ {
+ SdPage* pPage = (SdPage*) pPV->GetPage();
+
+ if (pPage)
+ {
+ if (!mbZoomOnPage)
+ {
+ // Gegenwaertigen MapMode beruecksichtigen
+ aSize = GetActiveWindow()->LogicToPixel( pPage->GetSize() );
+ }
+ else
+ {
+ // 1:1 Darstellung
+ MapMode aMapMode(MAP_100TH_MM);
+ aSize = GetActiveWindow()->LogicToPixel( pPage->GetSize(), aMapMode );
+ const_cast< DrawViewShell* >(this)->mbZoomOnPage = sal_True;
+ }
+ }
+ }
+
+ return(aSize);
+}
+
+
+/*************************************************************************
+|*
+|* Seite wird gehided
+|*
+\************************************************************************/
+
+void DrawViewShell::HidePage()
+{
+ FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
+ if (pFormShell != NULL)
+ pFormShell->PrepareClose (sal_False);
+}
+
+
+
+void DrawViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ WriteFrameViewData();
+
+ ViewShell::WriteUserDataSequence( rSequence, bBrowse );
+
+ const sal_Int32 nIndex = rSequence.getLength();
+ rSequence.realloc( nIndex + 1 );
+ rSequence[nIndex].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_ZoomOnPage ) );
+ rSequence[nIndex].Value <<= (sal_Bool)mbZoomOnPage;
+}
+
+void DrawViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ WriteFrameViewData();
+
+ ViewShell::ReadUserDataSequence( rSequence, bBrowse );
+
+ const sal_Int32 nLength = rSequence.getLength();
+ const com::sun::star::beans::PropertyValue *pValue = rSequence.getConstArray();
+ for (sal_Int16 i = 0 ; i < nLength; i++, pValue++ )
+ {
+ if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_ZoomOnPage ) ) )
+ {
+ sal_Bool bZoomPage = sal_False;
+ if( pValue->Value >>= bZoomPage )
+ {
+ mbZoomOnPage = bZoomPage;
+ }
+ }
+ }
+
+ if( mpFrameView->GetPageKind() != mePageKind )
+ {
+ mePageKind = mpFrameView->GetPageKind();
+
+ if (mePageKind == PK_NOTES)
+ {
+ SetHelpId( SID_NOTESMODE );
+ GetActiveWindow()->SetHelpId( CMD_SID_NOTESMODE );
+ GetActiveWindow()->SetUniqueId( CMD_SID_NOTESMODE );
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ SetHelpId( SID_HANDOUTMODE );
+ GetActiveWindow()->SetHelpId( CMD_SID_HANDOUTMODE );
+ GetActiveWindow()->SetUniqueId( CMD_SID_HANDOUTMODE );
+ }
+ else
+ {
+ SetHelpId( SD_IF_SDDRAWVIEWSHELL );
+ GetActiveWindow()->SetHelpId( HID_SDDRAWVIEWSHELL );
+ GetActiveWindow()->SetUniqueId( HID_SDDRAWVIEWSHELL );
+ }
+ }
+
+ ReadFrameViewData( mpFrameView );
+
+ if( !mbZoomOnPage )
+ {
+ const Rectangle aVisArea( mpFrameView->GetVisArea() );
+
+ if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ {
+ GetDocSh()->SetVisArea(aVisArea);
+ }
+
+ VisAreaChanged(aVisArea);
+
+ ::sd::View* pView = GetView();
+
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+
+ SetZoomRect(aVisArea);
+ }
+
+ ChangeEditMode (meEditMode, ! IsLayerModeActive());
+ ChangeEditMode (meEditMode, ! IsLayerModeActive());
+}
+
+void DrawViewShell::VisAreaChanged(const Rectangle& rRect)
+{
+ ViewShell::VisAreaChanged( rRect );
+
+ DrawController& rController = GetViewShellBase().GetDrawController();
+ rController.FireVisAreaChanged (rRect);
+}
+
+
+
+
+/** If there is a valid controller then create a new instance of
+ <type>AccessibleDrawDocumentView</type>. Otherwise delegate this call
+ to the base class to return a default object (probably an empty
+ reference).
+*/
+::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ DrawViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow)
+{
+ if (GetViewShellBase().GetController() != NULL)
+ {
+ accessibility::AccessibleDrawDocumentView* pDocumentView =
+ new accessibility::AccessibleDrawDocumentView (
+ pWindow,
+ this,
+ GetViewShellBase().GetController(),
+ pWindow->GetAccessibleParentWindow()->GetAccessible());
+ pDocumentView->Init();
+ return ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ (static_cast< ::com::sun::star::uno::XWeak*>(pDocumentView),
+ ::com::sun::star::uno::UNO_QUERY);
+ }
+ else
+ {
+ OSL_TRACE ("DrawViewShell::CreateAccessibleDocumentView: no controller");
+ return ViewShell::CreateAccessibleDocumentView (pWindow);
+ }
+}
+
+
+
+
+int DrawViewShell::GetActiveTabLayerIndex (void) const
+{
+ const LayerTabBar* pBar
+ = const_cast<DrawViewShell*>(this)->GetLayerTabControl ();
+ if (pBar != NULL)
+ return pBar->GetPagePos (pBar->GetCurPageId());
+ else
+ return -1;
+}
+
+
+
+
+void DrawViewShell::SetActiveTabLayerIndex (int nIndex)
+{
+ LayerTabBar* pBar = GetLayerTabControl ();
+ if (pBar != NULL)
+ {
+ // Ignore invalid indices silently.
+ if (nIndex>=0 && nIndex<pBar->GetPageCount())
+ {
+ // Tell the draw view and the tab control of the new active layer.
+ mpDrawView->SetActiveLayer (pBar->GetPageText (pBar->GetPageId ((sal_uInt16)nIndex)));
+ pBar->SetCurPageId (pBar->GetPageId ((sal_uInt16)nIndex));
+ }
+ }
+}
+
+
+
+
+TabControl* DrawViewShell::GetPageTabControl (void)
+{
+ return &maTabControl;
+}
+
+
+
+
+LayerTabBar* DrawViewShell::GetLayerTabControl (void)
+{
+ return mpLayerTabBar.get();
+}
+
+
+
+
+int DrawViewShell::GetTabLayerCount (void) const
+{
+ const LayerTabBar* pBar
+ = const_cast<DrawViewShell*>(this)->GetLayerTabControl ();
+ if (pBar != NULL)
+ return pBar->GetPageCount();
+ else
+ return 0;
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviews6.cxx b/sd/source/ui/view/drviews6.cxx
new file mode 100755
index 000000000000..800ee2756c97
--- /dev/null
+++ b/sd/source/ui/view/drviews6.cxx
@@ -0,0 +1,742 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include <vcl/metaact.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/svdograf.hxx>
+#ifndef _SVXIDS_HXX
+#include <svx/svxids.hrc>
+#endif
+#ifndef _FONTWORK_HXX
+#include <svx/fontwork.hxx>
+#endif
+#ifndef _BMPMASK_HXX
+#include <svx/bmpmask.hxx>
+#endif
+#ifndef _SVX_GALBRWS_HXX
+#include <svx/galbrws.hxx>
+#endif
+#ifndef _IMAPDLG_HXX
+#include <svx/imapdlg.hxx>
+#endif
+#include <svx/xftsfit.hxx>
+#include <svx/colrctrl.hxx>
+#include <svx/f3dchild.hxx>
+#include "optsitem.hxx"
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <svx/tbxcustomshapes.hxx>
+#ifndef _AVMEDIA_MEDIAPLAYER_HXX
+#include <avmedia/mediaplayer.hxx>
+#endif
+
+#include "app.hrc"
+#include "strings.hrc"
+#include "glob.hrc"
+
+#include "app.hxx"
+#include "animobjs.hxx"
+#include "AnimationChildWindow.hxx"
+#include "NavigatorChildWindow.hxx"
+#include "LayerDialogChildWindow.hxx"
+#include "sdresid.hxx"
+#include "fupoor.hxx"
+#include "fusldlg.hxx"
+#include "drawdoc.hxx"
+#include "fuexpand.hxx"
+#include "fusumry.hxx"
+#include "fucushow.hxx"
+#include "drawview.hxx"
+#include "FrameView.hxx"
+#include "Window.hxx"
+#include "DrawDocShell.hxx"
+#include "framework/FrameworkHelper.hxx"
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* SfxRequests fuer FontWork bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecFormText(SfxRequest& rReq)
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if(HasCurrentFunction(SID_PRESENTATION))
+ return;
+
+ CheckLineTo (rReq);
+
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+
+ if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() &&
+ mpDrawView && !mpDrawView->IsPresObjSelected() )
+ {
+ const SfxItemSet& rSet = *rReq.GetArgs();
+ const SfxPoolItem* pItem;
+
+ if ( mpDrawView->IsTextEdit() )
+ mpDrawView->SdrEndTextEdit();
+
+ if ( rSet.GetItemState(XATTR_FORMTXTSTDFORM, sal_True, &pItem) ==
+ SFX_ITEM_SET &&
+ ((const XFormTextStdFormItem*) pItem)->GetValue() != XFTFORM_NONE )
+ {
+
+ sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
+
+ SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*)GetViewFrame()->
+ GetChildWindow(nId)->GetWindow();
+
+ pDlg->CreateStdFormObj(*mpDrawView, *mpDrawView->GetSdrPageView(),
+ rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(),
+ ((const XFormTextStdFormItem*) pItem)->
+ GetValue());
+
+ if(HasCurrentFunction(SID_BEZIER_EDIT))
+ { // ggf. die richtige Editfunktion aktivieren
+ GetViewFrame()->GetDispatcher()->Execute(SID_SWITCH_POINTEDIT,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+ }
+ }
+ else
+ mpDrawView->SetAttributes(rSet);
+ }
+}
+
+/*************************************************************************
+|*
+|* Statuswerte fuer FontWork zurueckgeben
+|*
+\************************************************************************/
+
+void DrawViewShell::GetFormTextState(SfxItemSet& rSet)
+{
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ const SdrObject* pObj = NULL;
+ SvxFontWorkDialog* pDlg = NULL;
+
+ sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
+
+ if ( GetViewFrame()->HasChildWindow(nId) )
+ pDlg = (SvxFontWorkDialog*)(GetViewFrame()->GetChildWindow(nId)->GetWindow());
+
+ if ( rMarkList.GetMarkCount() == 1 )
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ if ( pObj == NULL || !pObj->ISA(SdrTextObj) ||
+ !((SdrTextObj*) pObj)->HasText() )
+ {
+// automatisches Auf/Zuklappen des FontWork-Dialog; erstmal deaktiviert
+// if ( pDlg )
+// pDlg->SetActive(sal_False);
+
+ rSet.DisableItem(XATTR_FORMTXTSTYLE);
+ rSet.DisableItem(XATTR_FORMTXTADJUST);
+ rSet.DisableItem(XATTR_FORMTXTDISTANCE);
+ rSet.DisableItem(XATTR_FORMTXTSTART);
+ rSet.DisableItem(XATTR_FORMTXTMIRROR);
+ rSet.DisableItem(XATTR_FORMTXTSTDFORM);
+ rSet.DisableItem(XATTR_FORMTXTHIDEFORM);
+ rSet.DisableItem(XATTR_FORMTXTOUTLINE);
+ rSet.DisableItem(XATTR_FORMTXTSHADOW);
+ rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR);
+ rSet.DisableItem(XATTR_FORMTXTSHDWXVAL);
+ rSet.DisableItem(XATTR_FORMTXTSHDWYVAL);
+ }
+ else
+ {
+ if ( pDlg )
+ {
+// pDlg->SetActive();
+ pDlg->SetColorTable(GetDoc()->GetColorTable());
+ }
+
+ SfxItemSet aSet( GetDoc()->GetPool() );
+ mpDrawView->GetAttributes( aSet );
+ rSet.Set( aSet );
+ }
+}
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Animator bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecAnimationWin( SfxRequest& rReq )
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if (HasCurrentFunction(SID_PRESENTATION))
+ return;
+
+ CheckLineTo (rReq);
+
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ switch( nSId )
+ {
+ case SID_ANIMATOR_INIT:
+ case SID_ANIMATOR_ADD:
+ case SID_ANIMATOR_CREATE:
+ {
+ AnimationWindow* pAnimWin;
+ sal_uInt16 nId = AnimationChildWindow::GetChildWindowId();
+ //((const SfxUInt16Item&)(rReq.GetArgs()->Get(nSId))).GetValue();
+
+ pAnimWin = static_cast<AnimationWindow*>(
+ GetViewFrame()->GetChildWindow(nId)->GetWindow());
+
+ if ( pAnimWin )
+ {
+ if( nSId == SID_ANIMATOR_ADD )
+ pAnimWin->AddObj( *mpDrawView );
+ else if( nSId == SID_ANIMATOR_CREATE )
+ pAnimWin->CreateAnimObj( *mpDrawView );
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* Statuswerte fuer Animator zurueckgeben
+|*
+|* nValue == 0 -> Kein Button
+|* nValue == 1 -> Button 'uebernehmen'
+|* nValue == 2 -> Button 'einzeln uebernehmen'
+|* nValue == 3 -> Buttons 'uebernehmen' und 'einzeln uebernehmen'
+|*
+\************************************************************************/
+
+void DrawViewShell::GetAnimationWinState( SfxItemSet& rSet )
+{
+ // Hier koennten Buttons etc. disabled werden
+ sal_uInt16 nValue;
+
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ sal_uLong nMarkCount = rMarkList.GetMarkCount();
+
+ if( nMarkCount == 0 )
+ nValue = 0;
+ else if( nMarkCount > 1 )
+ nValue = 3;
+ else // 1 Objekt
+ {
+ const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ sal_uInt32 nInv = pObj->GetObjInventor();
+ sal_uInt16 nId = pObj->GetObjIdentifier();
+ // 1 selektiertes Gruppenobjekt
+ if( nInv == SdrInventor && nId == OBJ_GRUP )
+ nValue = 3;
+ else if( nInv == SdrInventor && nId == OBJ_GRAF ) // Anim. GIF ?
+ {
+ sal_uInt16 nCount = 0;
+
+ if( ( (SdrGrafObj*) pObj )->IsAnimated() )
+ nCount = ( (SdrGrafObj*) pObj )->GetGraphic().GetAnimation().Count();
+ if( nCount > 0 )
+ nValue = 2;
+ else
+ nValue = 1;
+ }
+ else
+ nValue = 1;
+ }
+ rSet.Put( SfxUInt16Item( SID_ANIMATOR_STATE, nValue ) );
+}
+
+/*************************************************************************
+|*
+|* Statuswerte fuer SfxChildWindows setzen
+|*
+\************************************************************************/
+
+void DrawViewShell::SetChildWindowState( SfxItemSet& rSet )
+{
+ // Stati der SfxChild-Windows (Animator, Fontwork etc.)
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_FONTWORK ) )
+ {
+ sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId();
+ rSet.Put(SfxBoolItem(SID_FONTWORK, GetViewFrame()->HasChildWindow(nId)));
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_COLOR_CONTROL ) )
+ {
+ sal_uInt16 nId = SvxColorChildWindow::GetChildWindowId();
+ rSet.Put(SfxBoolItem(SID_COLOR_CONTROL, GetViewFrame()->HasChildWindow(nId)));
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ANIMATION_OBJECTS ) )
+ {
+ sal_uInt16 nId = AnimationChildWindow::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_ANIMATION_OBJECTS, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_NAVIGATOR ) )
+ {
+ sal_uInt16 nId = SID_NAVIGATOR;
+ rSet.Put( SfxBoolItem( SID_NAVIGATOR, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_BMPMASK ) )
+ {
+ sal_uInt16 nId = SvxBmpMaskChildWindow::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_BMPMASK, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GALLERY ) )
+ {
+ sal_uInt16 nId = GalleryChildWindow::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_GALLERY, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_IMAP ) )
+ {
+ sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_IMAP, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_LAYER_DIALOG_WIN ) )
+ {
+ sal_uInt16 nId = LayerDialogChildWindow::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_LAYER_DIALOG_WIN, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_3D_WIN ) )
+ {
+ sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_3D_WIN, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_AVMEDIA_PLAYER ) )
+ {
+ sal_uInt16 nId = ::avmedia::MediaPlayer::GetChildWindowId();
+ rSet.Put( SfxBoolItem( SID_AVMEDIA_PLAYER, GetViewFrame()->HasChildWindow( nId ) ) );
+ }
+}
+
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Pipette bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecBmpMask( SfxRequest& rReq )
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if (HasCurrentFunction(SID_PRESENTATION))
+ return;
+
+ switch ( rReq.GetSlot() )
+ {
+ case ( SID_BMPMASK_PIPETTE ) :
+ {
+ mbPipette = ( (const SfxBoolItem&) ( rReq.GetArgs()->
+ Get( SID_BMPMASK_PIPETTE ) ) ).GetValue();
+ }
+ break;
+
+ case ( SID_BMPMASK_EXEC ) :
+ {
+ SdrGrafObj* pObj = 0;
+ if( mpDrawView && mpDrawView->GetMarkedObjectList().GetMarkCount() )
+ pObj = dynamic_cast< SdrGrafObj* >( mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj() );
+
+ if ( pObj && !mpDrawView->IsTextEdit() )
+ {
+ SdrGrafObj* pNewObj = (SdrGrafObj*) pObj->Clone();
+ sal_Bool bCont = sal_True;
+
+ if( pNewObj->IsLinkedGraphic() )
+ {
+ QueryBox aQBox( (Window*) GetActiveWindow(), WB_YES_NO | WB_DEF_YES,
+ String( SdResId( STR_RELEASE_GRAPHICLINK ) ) );
+
+ if( RET_YES == aQBox.Execute() )
+ pNewObj->ReleaseGraphicLink();
+ else
+ {
+ delete pNewObj;
+ bCont = sal_False;
+ }
+ }
+
+ if( bCont )
+ {
+ const Graphic& rOldGraphic = pNewObj->GetGraphic();
+ const Graphic aNewGraphic( ( (SvxBmpMask*) GetViewFrame()->GetChildWindow(
+ SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
+ Mask( rOldGraphic ) );
+
+ if( aNewGraphic != rOldGraphic )
+ {
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+
+ pNewObj->SetEmptyPresObj( sal_False );
+ pNewObj->SetGraphic( ( (SvxBmpMask*) GetViewFrame()->GetChildWindow(
+ SvxBmpMaskChildWindow::GetChildWindowId() )->GetWindow() )->
+ Mask( pNewObj->GetGraphic() ) );
+
+ String aStr( mpDrawView->GetDescriptionOfMarkedObjects() );
+ aStr += (sal_Unicode)( ' ' ), aStr += String( SdResId( STR_EYEDROPPER ) );
+
+ mpDrawView->BegUndo( aStr );
+ mpDrawView->ReplaceObjectAtView( pObj, *pPV, pNewObj );
+ mpDrawView->EndUndo();
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void DrawViewShell::GetBmpMaskState( SfxItemSet& rSet )
+{
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ const SdrObject* pObj = NULL;
+ sal_uInt16 nId = SvxBmpMaskChildWindow::GetChildWindowId();
+ SvxBmpMask* pDlg = NULL;
+ sal_Bool bEnable = sal_False;
+
+ if ( GetViewFrame()->HasChildWindow( nId ) )
+ {
+ pDlg = (SvxBmpMask*) ( GetViewFrame()->GetChildWindow( nId )->GetWindow() );
+
+ if ( pDlg->NeedsColorTable() )
+ pDlg->SetColorTable( GetDoc()->GetColorTable() );
+ }
+
+ if ( rMarkList.GetMarkCount() == 1 )
+ pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ // valid graphic object?
+ if( pObj && pObj->ISA( SdrGrafObj ) && !( (SdrGrafObj*) pObj )->IsEPS() && !mpDrawView->IsTextEdit() )
+ bEnable = sal_True;
+
+ // put value
+ rSet.Put( SfxBoolItem( SID_BMPMASK_EXEC, bEnable ) );
+}
+
+/*************************************************************************
+|*
+|* SfxRequests fuer temporaere Funktionen
+|*
+\************************************************************************/
+
+void DrawViewShell::FuTemp04(SfxRequest& rReq)
+{
+ sal_uInt16 nSId = rReq.GetSlot();
+ switch( nSId )
+ {
+ case SID_FONTWORK:
+ {
+ if ( rReq.GetArgs() )
+ {
+ GetViewFrame()->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(SID_FONTWORK))).GetValue());
+ }
+ else
+ {
+ GetViewFrame()->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() );
+ }
+
+ GetViewFrame()->GetBindings().Invalidate(SID_FONTWORK);
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_COLOR_CONTROL:
+ {
+ if ( rReq.GetArgs() )
+ GetViewFrame()->SetChildWindow(SvxColorChildWindow::GetChildWindowId(),
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(SID_COLOR_CONTROL))).GetValue());
+ else
+ GetViewFrame()->ToggleChildWindow(SvxColorChildWindow::GetChildWindowId() );
+
+ GetViewFrame()->GetBindings().Invalidate(SID_COLOR_CONTROL);
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_EXTRUSION_TOOGLE:
+ case SID_EXTRUSION_TILT_DOWN:
+ case SID_EXTRUSION_TILT_UP:
+ case SID_EXTRUSION_TILT_LEFT:
+ case SID_EXTRUSION_TILT_RIGHT:
+ case SID_EXTRUSION_3D_COLOR:
+ case SID_EXTRUSION_DEPTH:
+ case SID_EXTRUSION_DIRECTION:
+ case SID_EXTRUSION_PROJECTION:
+ case SID_EXTRUSION_LIGHTING_DIRECTION:
+ case SID_EXTRUSION_LIGHTING_INTENSITY:
+ case SID_EXTRUSION_SURFACE:
+ case SID_EXTRUSION_DEPTH_FLOATER:
+ case SID_EXTRUSION_DIRECTION_FLOATER:
+ case SID_EXTRUSION_LIGHTING_FLOATER:
+ case SID_EXTRUSION_SURFACE_FLOATER:
+ case SID_EXTRUSION_DEPTH_DIALOG:
+ svx::ExtrusionBar::execute( mpDrawView, rReq, GetViewFrame()->GetBindings() );
+ Cancel();
+ rReq.Ignore ();
+ break;
+
+ case SID_FONTWORK_SHAPE:
+ case SID_FONTWORK_SHAPE_TYPE:
+ case SID_FONTWORK_ALIGNMENT:
+ case SID_FONTWORK_SAME_LETTER_HEIGHTS:
+ case SID_FONTWORK_CHARACTER_SPACING:
+ case SID_FONTWORK_KERN_CHARACTER_PAIRS:
+ case SID_FONTWORK_GALLERY_FLOATER:
+ case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
+ case SID_FONTWORK_ALIGNMENT_FLOATER:
+ case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
+ svx::FontworkBar::execute( mpDrawView, rReq, GetViewFrame()->GetBindings() );
+ Cancel();
+ rReq.Ignore ();
+ break;
+
+ case SID_BMPMASK:
+ {
+ GetViewFrame()->ToggleChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() );
+ GetViewFrame()->GetBindings().Invalidate( SID_BMPMASK );
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_GALLERY:
+ {
+ GetViewFrame()->ToggleChildWindow( GalleryChildWindow::GetChildWindowId() );
+ GetViewFrame()->GetBindings().Invalidate( SID_GALLERY );
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_NAVIGATOR:
+ {
+ if ( rReq.GetArgs() )
+ GetViewFrame()->SetChildWindow(SID_NAVIGATOR,
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(SID_NAVIGATOR))).GetValue());
+ else
+ GetViewFrame()->ToggleChildWindow( SID_NAVIGATOR );
+
+ GetViewFrame()->GetBindings().Invalidate(SID_NAVIGATOR);
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_ANIMATION_OBJECTS:
+ {
+ if ( rReq.GetArgs() )
+ GetViewFrame()->SetChildWindow(
+ AnimationChildWindow::GetChildWindowId(),
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(SID_ANIMATION_OBJECTS))).GetValue());
+ else
+ GetViewFrame()->ToggleChildWindow(
+ AnimationChildWindow::GetChildWindowId() );
+
+ GetViewFrame()->GetBindings().Invalidate(SID_ANIMATION_OBJECTS);
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_CUSTOM_ANIMATION_PANEL:
+ {
+ // Make the slide transition panel visible (expand it) in the
+ // tool pane.
+ framework::FrameworkHelper::Instance(GetViewShellBase())->RequestTaskPanel(
+ framework::FrameworkHelper::msCustomAnimationTaskPanelURL);
+
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_SLIDE_TRANSITIONS_PANEL:
+ {
+ // Make the slide transition panel visible (expand it) in the
+ // tool pane.
+ framework::FrameworkHelper::Instance(GetViewShellBase())->RequestTaskPanel(
+ framework::FrameworkHelper::msSlideTransitionTaskPanelURL);
+
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_3D_WIN:
+ {
+ if ( rReq.GetArgs() )
+ GetViewFrame()->SetChildWindow( Svx3DChildWindow::GetChildWindowId(),
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get( SID_3D_WIN ))).GetValue());
+ else
+ GetViewFrame()->ToggleChildWindow( Svx3DChildWindow::GetChildWindowId() );
+
+ GetViewFrame()->GetBindings().Invalidate( SID_3D_WIN );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_CONVERT_TO_3D_LATHE_FAST:
+ {
+ // Der Aufruf ist ausreichend. Die Initialisierung per Start3DCreation und CreateMirrorPolygons
+ // ist nicht mehr noetig, falls der Parameter sal_True uebergeben wird. Dann wird sofort und
+ // ohne Benutzereingriff ein gekippter Rotationskoerper mit einer Achse links neben dem
+ // Umschliessenden Rechteck der slektierten Objekte gezeichnet.
+ mpDrawView->SdrEndTextEdit();
+ if(GetActiveWindow())
+ GetActiveWindow()->EnterWait();
+ mpDrawView->End3DCreation(sal_True);
+ Cancel();
+ rReq.Ignore();
+ if(GetActiveWindow())
+ GetActiveWindow()->LeaveWait();
+ }
+ break;
+
+ case SID_PRESENTATION_DLG:
+ {
+ SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_CUSTOMSHOW_DLG:
+ {
+ SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_EXPAND_PAGE:
+ {
+ SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_SUMMARY_PAGE:
+ {
+ mpDrawView->SdrEndTextEdit();
+ SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_AVMEDIA_PLAYER:
+ {
+ GetViewFrame()->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() );
+ GetViewFrame()->GetBindings().Invalidate( SID_AVMEDIA_PLAYER );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_LAYER_DIALOG_WIN:
+ {
+ if ( rReq.GetArgs() )
+ {
+ GetViewFrame()->SetChildWindow(
+ LayerDialogChildWindow::GetChildWindowId(),
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(SID_LAYER_DIALOG_WIN))).GetValue());
+ }
+ else
+ {
+ GetViewFrame()->ToggleChildWindow(
+ LayerDialogChildWindow::GetChildWindowId());
+ }
+
+ GetViewFrame()->GetBindings().Invalidate(SID_LAYER_DIALOG_WIN);
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_DISPLAY_MASTER_BACKGROUND:
+ case SID_DISPLAY_MASTER_OBJECTS:
+ {
+ // Determine current page and toggle visibility of layers
+ // associated with master page background or master page shapes.
+ SdPage* pPage = GetActualPage();
+ if (pPage != NULL
+ && GetDoc() != NULL)
+ {
+ SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+ SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
+ sal_uInt8 aLayerId;
+ if (nSId == SID_DISPLAY_MASTER_BACKGROUND)
+ aLayerId = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
+ else
+ aLayerId = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
+ aVisibleLayers.Set(aLayerId, !aVisibleLayers.IsSet(aLayerId));
+ pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
+ }
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ default:
+ {
+ DBG_ASSERT( 0, "Slot ohne Funktion" );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
new file mode 100755
index 000000000000..acdcb58b5daf
--- /dev/null
+++ b/sd/source/ui/view/drviews7.cxx
@@ -0,0 +1,1741 @@
+/*************************************************************************
+ *
+ * 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 <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <svx/fmglob.hxx>
+#include <svx/globl3d.hxx>
+#include <svx/svdouno.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/outlobj.hxx>
+#include <svx/svxids.hrc>
+#include <svx/svdpagv.hxx>
+#include <svx/clipfmtitem.hxx>
+#include <svx/fmshell.hxx>
+#include <svl/eitem.hxx>
+#include <svl/aeitem.hxx>
+#include <svl/stritem.hxx>
+#include <svl/visitem.hxx>
+#include <svl/whiter.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdograf.hxx>
+#include <editeng/unolingu.hxx>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+
+// #UndoRedo#
+#include <svl/slstitm.hxx>
+#include <sfx2/app.hxx>
+#include <svtools/insdlg.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svl/languageoptions.hxx>
+#include <comphelper/processfactory.hxx>
+#include <sfx2/request.hxx>
+
+
+#include <svx/pfiledlg.hxx>
+#include <svx/grafctrl.hxx>
+#include <svtools/cliplistener.hxx>
+#include <sfx2/viewfrm.hxx>
+
+#include "app.hrc"
+#include "glob.hrc"
+#include "res_bmp.hrc"
+#include "PresentationViewShell.hxx"
+
+#include "misc.hxx"
+#include "Outliner.hxx"
+#include "drawdoc.hxx"
+#include "sdresid.hxx"
+#include "sdpage.hxx"
+#include "Client.hxx"
+#include "DrawDocShell.hxx"
+#include "zoomlist.hxx"
+#include "slideshow.hxx"
+#include "drawview.hxx"
+#include "ViewShellBase.hxx"
+#include "ViewShellManager.hxx"
+#include "LayerTabBar.hxx"
+#include "fupoor.hxx"
+#include "Window.hxx"
+#include "fuediglu.hxx"
+#include "fubullet.hxx"
+#include "fuformatpaintbrush.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::linguistic2;
+
+/** Create a list of clipboard formats that are supported both from the
+ current clipboard content and the DrawViewShell.
+ The list is stored in a new instance of SvxClipboardFmtItem.
+*/
+::std::auto_ptr<SvxClipboardFmtItem> GetSupportedClipboardFormats (
+ TransferableDataHelper& rDataHelper)
+{
+ ::std::auto_ptr<SvxClipboardFmtItem> pResult (
+ new SvxClipboardFmtItem(SID_CLIPBOARD_FORMAT_ITEMS));
+
+ sal_uInt32 nFormatCount (rDataHelper.GetFormatCount());
+ for (sal_uInt32 i=0; i<nFormatCount; i++)
+ {
+ const SotFormatStringId nTestFormat = rDataHelper.GetFormat(i);
+
+ // Check if the current format is the same as one that has already
+ // been handled.
+ bool bDuplicate (false);
+ for (sal_uInt32 j=0; j<i; j++)
+ {
+ if (nTestFormat == rDataHelper.GetFormat(j))
+ {
+ bDuplicate = true;
+ break;
+ }
+ }
+
+ // Look up the format among those that are supported by the
+ // DrawViewShell.
+ if ( ! bDuplicate)
+ {
+ switch (nTestFormat)
+ {
+ case SOT_FORMATSTR_ID_EMBED_SOURCE:
+ {
+ String sName;
+
+ TransferableObjectDescriptor aDescriptor;
+ if (rDataHelper.GetTransferableObjectDescriptor(
+ SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aDescriptor))
+ {
+ sName = aDescriptor.maTypeName;
+ }
+ if (sName.Len() > 0)
+ pResult->AddClipbrdFormat(nTestFormat, sName);
+ else
+ pResult->AddClipbrdFormat(nTestFormat);
+
+ break;
+ }
+
+ case SOT_FORMATSTR_ID_LINK_SOURCE:
+ case SOT_FORMATSTR_ID_DRAWING:
+ case SOT_FORMATSTR_ID_SVXB:
+ case FORMAT_GDIMETAFILE:
+ case FORMAT_BITMAP:
+ case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK:
+ case FORMAT_STRING:
+ case SOT_FORMATSTR_ID_HTML:
+ case FORMAT_RTF:
+ case SOT_FORMATSTR_ID_EDITENGINE:
+ pResult->AddClipbrdFormat(nTestFormat);
+ break;
+ }
+ }
+ }
+
+ // Check some OLE formats whose names are handled differently.
+ SotFormatStringId nFormat (SOT_FORMATSTR_ID_EMBED_SOURCE_OLE);
+ bool bHasFormat (rDataHelper.HasFormat(nFormat));
+ if ( ! bHasFormat)
+ {
+ bHasFormat = rDataHelper.HasFormat(nFormat);
+ }
+ if (bHasFormat)
+ {
+ String sName;
+ String sSource;
+ if (SvPasteObjectHelper::GetEmbeddedName (rDataHelper, sName, sSource, nFormat))
+ pResult->AddClipbrdFormat (nFormat, sName);
+ }
+
+ return pResult;
+}
+
+namespace sd {
+
+IMPL_LINK( DrawViewShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ mbPastePossible = ( pDataHelper->GetFormatCount() != 0 );
+
+ // Update the list of supported clipboard formats according to the
+ // new clipboard content.
+ // There are some stack traces that indicate the possibility of the
+ // DrawViewShell destructor called during the call to
+ // GetSupportedClipboardFormats(). If that really has happened then
+ // exit immediately.
+ TransferableDataHelper aDataHelper (
+ TransferableDataHelper::CreateFromSystemClipboard(GetActiveWindow()));
+ ::std::auto_ptr<SvxClipboardFmtItem> pFormats (GetSupportedClipboardFormats(aDataHelper));
+ if (mpDrawView == NULL)
+ return 0;
+ mpCurrentClipboardFormats = pFormats;
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Status (Enabled/Disabled) von Menue-SfxSlots setzen
+|*
+\************************************************************************/
+
+void DrawViewShell::GetMenuState( SfxItemSet &rSet )
+{
+ if (mpDrawView == NULL)
+ {
+ // This assertion and return are here to prevent crashes like that
+ // of issue #126202#.
+ DBG_ASSERT(mpDrawView!=NULL, "Please report this assertion to the Impress team.");
+ return;
+ }
+
+ ViewShell::GetMenuState(rSet);
+ sal_Bool bDisableVerticalText = !SvtLanguageOptions().IsVerticalTextEnabled();
+
+ if ( bDisableVerticalText )
+ {
+ rSet.DisableItem( SID_DRAW_FONTWORK_VERTICAL );
+ rSet.DisableItem( SID_DRAW_CAPTION_VERTICAL );
+ rSet.DisableItem( SID_TEXT_FITTOSIZE_VERTICAL );
+ rSet.DisableItem( SID_DRAW_TEXT_VERTICAL );
+ }
+
+ FASTBOOL bConvertToPathPossible = mpDrawView->IsConvertToPathObjPossible(sal_False);
+
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ const sal_uLong nMarkCount = rMarkList.GetMarkCount();
+
+ //format paintbrush
+ FuFormatPaintBrush::GetMenuState( *this, rSet );
+
+ // Stati der SfxChild-Windows (Animator, Fontwork etc.)
+ SetChildWindowState( rSet );
+
+ // Images der Toolboxen mappen (nur Zoom)
+ UpdateToolboxImages( rSet, sal_False );
+
+ if(HasCurrentFunction())
+ {
+ sal_uInt16 nSId = GetCurrentFunction()->GetSlotID();
+
+ rSet.Put( SfxBoolItem( nSId, sal_True ) );
+
+ // Bewirkt ein uncheck eines simulierten Slots
+ sal_uInt16 nId = GetIdBySubId( nSId );
+
+ // Images der Toolboxen mappen
+ UpdateToolboxImages( rSet );
+
+ if( nId != SID_ZOOM_TOOLBOX &&
+ nSId != SID_DRAWTBX_INSERT &&
+ nSId != SID_POSITION &&
+ nSId != SID_OBJECT_ALIGN )
+ {
+ if( nId != SID_OBJECT_CHOOSE_MODE )
+ rSet.Put( TbxImageItem( SID_OBJECT_CHOOSE_MODE, 0 ) );
+ if( nId != SID_DRAWTBX_TEXT )
+ rSet.Put( TbxImageItem( SID_DRAWTBX_TEXT, 0 ) );
+ if( nId != SID_DRAWTBX_RECTANGLES )
+ rSet.Put( TbxImageItem( SID_DRAWTBX_RECTANGLES, 0 ) );
+ if( nId != SID_DRAWTBX_ELLIPSES )
+ rSet.Put( TbxImageItem( SID_DRAWTBX_ELLIPSES, 0 ) );
+ if( nId != SID_DRAWTBX_LINES )
+ rSet.Put( TbxImageItem( SID_DRAWTBX_LINES, 0 ) );
+ if( nId != SID_DRAWTBX_ARROWS )
+ rSet.Put( TbxImageItem( SID_DRAWTBX_ARROWS, 0 ) );
+ if( nId != SID_DRAWTBX_3D_OBJECTS )
+ rSet.Put( TbxImageItem( SID_DRAWTBX_3D_OBJECTS, 0 ) );
+ if( nId != SID_DRAWTBX_CONNECTORS )
+ rSet.Put( TbxImageItem( SID_DRAWTBX_CONNECTORS, 0 ) );
+ }
+ }
+
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+
+ GetMenuStateSel(rSet);
+
+ if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_ASSIGN_LAYOUT))
+ {
+ bool bDisable = true;
+ if( pPageView )
+ {
+ SdPage* pPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
+
+ if( pPage && !pPage->IsMasterPage() )
+ {
+ rSet.Put( SfxUInt32Item( SID_ASSIGN_LAYOUT, static_cast< sal_uInt32 >(pPage->GetAutoLayout()) ) );
+ bDisable = false;
+ }
+ }
+
+ if(bDisable)
+ {
+ rSet.DisableItem(SID_ASSIGN_LAYOUT);
+ }
+ }
+
+ if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_EXPAND_PAGE))
+ {
+ bool bDisable = true;
+ if( pPageView )
+ {
+ SdPage* pPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
+
+ if( pPage && (pPage->GetPageKind() == PK_STANDARD) && !pPage->IsMasterPage() )
+ {
+ SdrObject* pObj = pPage->GetPresObj(PRESOBJ_OUTLINE);
+
+ if (pObj!=NULL )
+ {
+ if( !pObj->IsEmptyPresObj() )
+ {
+ bDisable = false;
+ }
+ else
+ {
+ // check if the object is in edit, than its temporarely not empty
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
+ if( pTextObj )
+ {
+ OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject();
+ if( pParaObj )
+ {
+ delete pParaObj;
+ bDisable = false;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if(bDisable)
+ {
+ rSet.DisableItem(SID_EXPAND_PAGE);
+ }
+ }
+
+ if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_SUMMARY_PAGE))
+ {
+ bool bDisable = true;
+ if( pPageView )
+ {
+ SdPage* pPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
+
+ if( pPage && (pPage->GetPageKind() == PK_STANDARD) && !pPage->IsMasterPage() )
+ {
+ SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE);
+
+ if(pObj && !pObj->IsEmptyPresObj())
+ {
+ bDisable = false;
+ }
+ }
+ }
+
+ if(bDisable)
+ {
+ rSet.DisableItem(SID_SUMMARY_PAGE);
+ }
+ }
+
+ if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_ASSIGN_LAYOUT))
+ {
+ bool bDisable = true;
+ if( pPageView )
+ {
+ SdPage* pPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
+
+ if( pPage && !pPage->IsMasterPage() )
+ {
+ rSet.Put( SfxUInt32Item(SID_ASSIGN_LAYOUT, pPage->GetAutoLayout()) );
+ bDisable = false;
+ }
+ }
+
+ if(bDisable)
+ {
+ rSet.DisableItem(SID_ASSIGN_LAYOUT);
+ }
+ }
+
+ // Starten der Praesentation moeglich?
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PRESENTATION ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_REHEARSE_TIMINGS ) )
+ {
+ sal_Bool bDisable = sal_True;
+ sal_uInt16 nCount = GetDoc()->GetSdPageCount( PK_STANDARD );
+
+ for( sal_uInt16 i = 0; i < nCount && bDisable; i++ )
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
+
+ if( !pPage->IsExcluded() )
+ bDisable = sal_False;
+ }
+
+ if( bDisable || GetDocSh()->IsPreview())
+ {
+ rSet.DisableItem( SID_PRESENTATION );
+ rSet.DisableItem( SID_REHEARSE_TIMINGS );
+ }
+ }
+
+ // Klebepunkte
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_EDITMODE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_INSERT_POINT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_PERCENT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR_LEFT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR_RIGHT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR_TOP ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_ESCDIR_BOTTOM ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_HORZALIGN_CENTER ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_HORZALIGN_LEFT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_HORZALIGN_RIGHT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_VERTALIGN_CENTER ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_VERTALIGN_TOP ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GLUE_VERTALIGN_BOTTOM ) )
+ {
+ // Prozent
+ TRISTATE eState = mpDrawView->IsMarkedGluePointsPercent();
+ if( eState == STATE_DONTKNOW )
+ rSet.InvalidateItem( SID_GLUE_PERCENT );
+ else
+ rSet.Put( SfxBoolItem( SID_GLUE_PERCENT, eState == STATE_CHECK ) );
+
+ // Bei Prozent hat Alignment keinen Effekt
+ if( eState == STATE_CHECK )
+ {
+ rSet.DisableItem( SID_GLUE_HORZALIGN_CENTER );
+ rSet.DisableItem( SID_GLUE_HORZALIGN_LEFT );
+ rSet.DisableItem( SID_GLUE_HORZALIGN_RIGHT );
+ rSet.DisableItem( SID_GLUE_VERTALIGN_CENTER );
+ rSet.DisableItem( SID_GLUE_VERTALIGN_TOP );
+ rSet.DisableItem( SID_GLUE_VERTALIGN_BOTTOM );
+ }
+ else
+ {
+ // Horizontale Ausrichtung
+ sal_uInt16 nHorz = mpDrawView->GetMarkedGluePointsAlign( sal_False );
+ rSet.Put( SfxBoolItem( SID_GLUE_HORZALIGN_CENTER, nHorz == SDRHORZALIGN_CENTER ) );
+ rSet.Put( SfxBoolItem( SID_GLUE_HORZALIGN_LEFT, nHorz == SDRHORZALIGN_LEFT ) );
+ rSet.Put( SfxBoolItem( SID_GLUE_HORZALIGN_RIGHT, nHorz == SDRHORZALIGN_RIGHT ) );
+ // Vertikale Ausrichtung
+ sal_uInt16 nVert = mpDrawView->GetMarkedGluePointsAlign( sal_True );
+ rSet.Put( SfxBoolItem( SID_GLUE_VERTALIGN_CENTER, nVert == SDRVERTALIGN_CENTER ) );
+ rSet.Put( SfxBoolItem( SID_GLUE_VERTALIGN_TOP, nVert == SDRVERTALIGN_TOP ) );
+ rSet.Put( SfxBoolItem( SID_GLUE_VERTALIGN_BOTTOM, nVert == SDRVERTALIGN_BOTTOM ) );
+ }
+
+ // Punkt einfuegen
+ rSet.Put( SfxBoolItem( SID_GLUE_INSERT_POINT, mpDrawView->IsInsGluePointMode() ) );
+
+ // Autrittsrichtung
+ // Links
+ eState = mpDrawView->IsMarkedGluePointsEscDir( SDRESC_LEFT );
+ if( eState == STATE_DONTKNOW )
+ rSet.InvalidateItem( SID_GLUE_ESCDIR_LEFT );
+ else
+ rSet.Put( SfxBoolItem( SID_GLUE_ESCDIR_LEFT, eState == STATE_CHECK ) );
+ // Rechts
+ eState = mpDrawView->IsMarkedGluePointsEscDir( SDRESC_RIGHT );
+ if( eState == STATE_DONTKNOW )
+ rSet.InvalidateItem( SID_GLUE_ESCDIR_RIGHT );
+ else
+ rSet.Put( SfxBoolItem( SID_GLUE_ESCDIR_RIGHT, eState == STATE_CHECK ) );
+ // Oben
+ eState = mpDrawView->IsMarkedGluePointsEscDir( SDRESC_TOP );
+ if( eState == STATE_DONTKNOW )
+ rSet.InvalidateItem( SID_GLUE_ESCDIR_TOP );
+ else
+ rSet.Put( SfxBoolItem( SID_GLUE_ESCDIR_TOP, eState == STATE_CHECK ) );
+ // Unten
+ eState = mpDrawView->IsMarkedGluePointsEscDir( SDRESC_BOTTOM );
+ if( eState == STATE_DONTKNOW )
+ rSet.InvalidateItem( SID_GLUE_ESCDIR_BOTTOM );
+ else
+ rSet.Put( SfxBoolItem( SID_GLUE_ESCDIR_BOTTOM, eState == STATE_CHECK ) );
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_GRID_FRONT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_HELPLINES_FRONT ) )
+ {
+ rSet.Put( SfxBoolItem( SID_GRID_FRONT, mpDrawView->IsGridFront() ) );
+ rSet.Put( SfxBoolItem( SID_HELPLINES_FRONT, mpDrawView->IsHlplFront() ) );
+ }
+
+ if (!mpDrawView->IsFrameDragSingles())
+ rSet.Put(SfxBoolItem(SID_BEZIER_EDIT, sal_True));
+ else
+ rSet.Put(SfxBoolItem(SID_BEZIER_EDIT, sal_False));
+
+ if(dynamic_cast<FuEditGluePoints*>( GetCurrentFunction().get()))
+ rSet.Put(SfxBoolItem(SID_GLUE_EDITMODE, sal_True));
+ else
+ rSet.Put(SfxBoolItem(SID_GLUE_EDITMODE, sal_False));
+
+ if( !mpDrawView->IsMirrorAllowed( sal_True, sal_True ) )
+ {
+ rSet.DisableItem( SID_HORIZONTAL );
+ rSet.DisableItem( SID_VERTICAL );
+ }
+
+ if( !mpDrawView->IsMirrorAllowed() )
+ {
+ rSet.DisableItem( SID_OBJECT_MIRROR );
+// rSet.DisableItem( SID_CONVERT_TO_3D_LATHE );
+// rSet.DisableItem( SID_CONVERT_TO_3D_LATHE_FAST );
+ }
+
+ // interactive transparence control
+ if(!mpDrawView->IsTransparenceAllowed())
+ {
+ rSet.DisableItem( SID_OBJECT_TRANSPARENCE );
+ }
+
+ // interactive gradient control
+ if(!mpDrawView->IsGradientAllowed())
+ {
+ rSet.DisableItem( SID_OBJECT_GRADIENT );
+ }
+
+ // Morphen ggf. disablen
+ if ( !mpDrawView->IsMorphingAllowed() )
+ rSet.DisableItem( SID_POLYGON_MORPHING );
+
+ // Vectorize ggf. disablen
+ if ( !mpDrawView->IsVectorizeAllowed() )
+ rSet.DisableItem( SID_VECTORIZE );
+
+ if( !mpDrawView->IsReverseOrderPossible() )
+ {
+ rSet.DisableItem( SID_REVERSE_ORDER );
+ }
+
+ if ( !bConvertToPathPossible &&
+ !mpDrawView->IsCrookAllowed( mpDrawView->IsCrookNoContortion() ) )
+ {
+ // Implizite Wandlung in Kurve nicht moeglich
+ rSet.DisableItem(SID_OBJECT_CROOK_ROTATE);
+ rSet.DisableItem(SID_OBJECT_CROOK_SLANT);
+ rSet.DisableItem(SID_OBJECT_CROOK_STRETCH);
+ }
+
+ if ( !mpDrawView->IsGroupEntered() )
+ {
+ rSet.DisableItem( SID_LEAVE_GROUP );
+ rSet.Put( SfxBoolItem( SID_LEAVE_ALL_GROUPS, sal_False ) );
+ rSet.ClearItem( SID_LEAVE_ALL_GROUPS );
+ rSet.DisableItem( SID_LEAVE_ALL_GROUPS );
+ }
+ else
+ rSet.Put( SfxBoolItem( SID_LEAVE_ALL_GROUPS, sal_True ) );
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_THESAURUS ) )
+ {
+ if ( !mpDrawView->IsTextEdit() )
+ {
+ rSet.DisableItem( SID_THESAURUS );
+ }
+ else
+ {
+ LanguageType eLang = GetDoc()->GetLanguage( EE_CHAR_LANGUAGE );
+ Reference< XThesaurus > xThesaurus( LinguMgr::GetThesaurus() );
+ Locale aLocale;
+
+ SvxLanguageToLocale( aLocale, eLang );
+
+ if (!xThesaurus.is() || eLang == LANGUAGE_NONE || !xThesaurus->hasLocale(aLocale) )
+ rSet.DisableItem( SID_THESAURUS );
+ }
+ }
+
+ if ( !mpDrawView->IsTextEdit() )
+ {
+ rSet.DisableItem( SID_THESAURUS );
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SELECTALL ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SIZE_ALL ) )
+ {
+ if( pPageView && pPageView->GetObjList()->GetObjCount() == 0 )
+ {
+ // Sollte disabled sein, wenn kein Objekt auf der Zeichenflaeche ist:
+ rSet.DisableItem( SID_SELECTALL );
+ rSet.DisableItem( SID_SIZE_ALL );
+ }
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONTEXT ) )
+ rSet.Put( SfxStringItem( SID_CONTEXT, mpDrawView->GetStatusText() ) );
+
+ // clipboard (paste)
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE_SPECIAL ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) )
+ {
+ if ( !mpClipEvtLstnr )
+ {
+ // SSA: #108717# avoid clipboard initialization for
+ // read-only presentation views (workaround for NT4.0
+ // clipboard prob...)
+ if( !ISA(PresentationViewShell) )
+ {
+ // create listener
+ mpClipEvtLstnr = new TransferableClipboardListener( LINK( this, DrawViewShell, ClipboardChanged ) );
+ mpClipEvtLstnr->acquire();
+ mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_True );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
+ mbPastePossible = ( aDataHelper.GetFormatCount() != 0 );
+ }
+ else
+ mbPastePossible = sal_False;
+ }
+
+ if( !mbPastePossible )
+ {
+ rSet.DisableItem( SID_PASTE );
+ rSet.DisableItem( SID_PASTE_SPECIAL );
+ rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ else if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CLIPBOARD_FORMAT_ITEMS ) )
+ {
+ if (mpCurrentClipboardFormats.get() != NULL)
+ rSet.Put(*mpCurrentClipboardFormats);
+ }
+ }
+
+ if ( !bConvertToPathPossible )
+ {
+ rSet.DisableItem(SID_CHANGEBEZIER);
+ }
+
+ if (mpDrawView == NULL)
+ {
+ // When we come to this line then we probably have another
+ // incarnation of issue #126202#. The mpDrawView was not NULL but is
+ // now. The reason for this may be that the DrawViewShell has been
+ // destroyed in the mean time.
+ // We can only return immediately and hope that the deleted
+ // DrawViewShell is not called again.
+ DBG_ASSERT(mpDrawView!=NULL, "Please report this assertion to the Impress team.");
+ return;
+ }
+
+ if( !( mpDrawView->IsConvertToPolyObjPossible(sal_False) || mpDrawView->IsVectorizeAllowed() ) )
+ rSet.DisableItem(SID_CHANGEPOLYGON);
+
+ if( !( mpDrawView->IsConvertToPolyObjPossible(sal_False) || mpDrawView->IsConvertToContourPossible() ) )
+ rSet.DisableItem(SID_CONVERT_TO_CONTOUR);
+
+ if ( !mpDrawView->IsConvertTo3DObjPossible() )
+ {
+ rSet.DisableItem(SID_CONVERT_TO_3D);
+ rSet.DisableItem(SID_CONVERT_TO_3D_LATHE);
+ rSet.DisableItem(SID_CONVERT_TO_3D_LATHE_FAST);
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MANAGE_LINKS ) )
+ {
+ if ( GetDoc()->GetLinkCount() == 0 )
+ {
+ rSet.DisableItem(SID_MANAGE_LINKS);
+ }
+ }
+
+ if (mePageKind == PK_HANDOUT)
+ {
+ rSet.DisableItem(SID_PRESENTATION_LAYOUT);
+ rSet.DisableItem(SID_SELECT_BACKGROUND);
+ }
+
+ if (mePageKind == PK_NOTES)
+ {
+ rSet.DisableItem(SID_INSERTPAGE);
+ rSet.DisableItem(SID_RENAMEPAGE);
+ rSet.DisableItem(SID_RENAMEPAGE_QUICK);
+ rSet.DisableItem(SID_DUPLICATE_PAGE);
+ rSet.ClearItem(SID_ANIMATION_OBJECTS);
+ rSet.DisableItem(SID_ANIMATION_OBJECTS);
+ rSet.DisableItem(SID_ANIMATION_EFFECTS);
+
+ if (meEditMode == EM_MASTERPAGE)
+ rSet.DisableItem(SID_MODIFYPAGE);
+
+ rSet.DisableItem(SID_SELECT_BACKGROUND);
+ rSet.DisableItem(SID_INSERTLAYER);
+ rSet.DisableItem(SID_LAYERMODE);
+ rSet.DisableItem(SID_INSERTFILE);
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ rSet.DisableItem(SID_INSERTPAGE);
+ rSet.DisableItem(SID_DUPLICATE_PAGE);
+ rSet.ClearItem(SID_ANIMATION_OBJECTS);
+ rSet.DisableItem(SID_ANIMATION_OBJECTS);
+ rSet.DisableItem(SID_ANIMATION_EFFECTS);
+ rSet.DisableItem(SID_RENAMEPAGE);
+ rSet.DisableItem(SID_RENAMEPAGE_QUICK);
+ rSet.DisableItem(SID_INSERTLAYER);
+ rSet.DisableItem(SID_MODIFYLAYER);
+ rSet.DisableItem(SID_RENAMELAYER);
+ rSet.DisableItem(SID_LAYERMODE);
+ rSet.DisableItem(SID_INSERTFILE);
+ rSet.DisableItem(SID_PAGEMODE);
+ rSet.DisableItem(SID_SELECT_BACKGROUND);
+ }
+ else
+ {
+ if (meEditMode == EM_MASTERPAGE)
+ {
+ rSet.DisableItem(SID_INSERTPAGE);
+ rSet.DisableItem(SID_DUPLICATE_PAGE);
+ rSet.DisableItem(SID_MODIFYPAGE);
+ rSet.ClearItem(SID_ANIMATION_OBJECTS);
+ rSet.DisableItem(SID_ANIMATION_OBJECTS);
+ }
+
+ rSet.Put (SfxBoolItem (SID_LAYERMODE, IsLayerModeActive()));
+ }
+
+ if ( ! IsLayerModeActive())
+ {
+ rSet.DisableItem( SID_INSERTLAYER );
+ rSet.DisableItem( SID_MODIFYLAYER );
+ rSet.DisableItem( SID_DELETE_LAYER );
+ rSet.DisableItem( SID_RENAMELAYER );
+ }
+
+ if (meEditMode == EM_PAGE)
+ {
+ /**********************************************************************
+ * Seiten-Modus
+ **********************************************************************/
+ rSet.Put(SfxBoolItem(SID_PAGEMODE, sal_True));
+ rSet.Put(SfxBoolItem(SID_MASTERPAGE, sal_False));
+ rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_False));
+ rSet.Put(SfxBoolItem(SID_NOTES_MASTERPAGE, sal_False));
+ rSet.Put(SfxBoolItem(SID_HANDOUT_MASTERPAGE, sal_False));
+
+ if (mePageKind == PK_STANDARD &&
+ rSet.GetItemState(SID_TITLE_MASTERPAGE) == SFX_ITEM_AVAILABLE)
+ {
+ // Gibt es eine Seite mit dem AutoLayout "Titel"?
+ sal_Bool bDisable = sal_True;
+ sal_uInt16 i = 0;
+ sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
+
+ while (i < nCount && bDisable)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
+
+ if (pPage->GetAutoLayout() == AUTOLAYOUT_TITLE)
+ {
+ bDisable = sal_False;
+ }
+
+ i++;
+ }
+
+ if (bDisable)
+ {
+ rSet.DisableItem(SID_TITLE_MASTERPAGE);
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem(SID_TITLE_MASTERPAGE, sal_False));
+ }
+ }
+ else
+ {
+ rSet.DisableItem(SID_TITLE_MASTERPAGE);
+ }
+
+ rSet.DisableItem (SID_INSERT_MASTER_PAGE);
+ rSet.DisableItem (SID_DELETE_MASTER_PAGE);
+ rSet.DisableItem (SID_RENAME_MASTER_PAGE);
+ rSet.DisableItem (SID_CLOSE_MASTER_VIEW);
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem(SID_PAGEMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_MASTERPAGE, sal_True));
+
+ /**********************************************************************
+ * Hintergrundseiten-Modus
+ **********************************************************************/
+ if (mePageKind == PK_STANDARD)
+ {
+ rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_True));
+ rSet.Put(SfxBoolItem(SID_NOTES_MASTERPAGE, sal_False));
+ rSet.Put(SfxBoolItem(SID_HANDOUT_MASTERPAGE, sal_False));
+
+ if (rSet.GetItemState(SID_TITLE_MASTERPAGE) == SFX_ITEM_AVAILABLE)
+ {
+ sal_Bool bCheck = sal_False;
+ sal_Bool bDisable = sal_True;
+ if( pPageView )
+ {
+ SdPage* pMPage = dynamic_cast< SdPage* >( pPageView->GetPage() );
+
+ sal_uInt16 i = 0;
+ sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
+
+ // Referenziert eine Seite mit dem AutoLayout "Titel" die
+ // aktuelle MasterPage?
+ while (i < nCount && !bCheck && bDisable)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
+
+ // Seite referenziert aktuelle MasterPage
+ if (pPage->GetAutoLayout() == AUTOLAYOUT_TITLE)
+ {
+ // Eine Seite hat das AutoLayout "Titel"
+ bDisable = sal_False;
+
+ SdPage& rRefMPage = (SdPage&)(pPage->TRG_GetMasterPage());
+
+ if(&rRefMPage == pMPage)
+ {
+ // Eine Seite mit dem AutoLayout "Titel"
+ // referenziert die aktuelle MasterPage
+ bCheck = sal_True;
+ }
+ }
+
+ i++;
+ }
+ }
+
+ if (bCheck)
+ {
+ rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_False));
+ }
+
+ rSet.Put(SfxBoolItem(SID_TITLE_MASTERPAGE, bCheck));
+
+ if (bDisable)
+ {
+ rSet.ClearItem(SID_TITLE_MASTERPAGE);
+ rSet.DisableItem(SID_TITLE_MASTERPAGE);
+ }
+ }
+ }
+ else if (mePageKind == PK_NOTES)
+ {
+ rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_False));
+ rSet.DisableItem(SID_TITLE_MASTERPAGE);
+ rSet.Put(SfxBoolItem(SID_NOTES_MASTERPAGE, sal_True));
+ rSet.Put(SfxBoolItem(SID_HANDOUT_MASTERPAGE, sal_False));
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ rSet.Put(SfxBoolItem(SID_SLIDE_MASTERPAGE, sal_False));
+ rSet.DisableItem(SID_TITLE_MASTERPAGE);
+ rSet.Put(SfxBoolItem(SID_NOTES_MASTERPAGE, sal_False));
+ rSet.Put(SfxBoolItem(SID_HANDOUT_MASTERPAGE, sal_True));
+ }
+ }
+
+ // Status der Lineale setzen
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_RULER ) )
+ rSet.Put( SfxBoolItem( SID_RULER, HasRuler() ) );
+
+ // nicht die letzte Seite oder eine Masterpage loeschen
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DELETE_PAGE )
+ || SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DELETE_MASTER_PAGE ) )
+ {
+ if (maTabControl.GetPageCount() == 1 ||
+ meEditMode == EM_MASTERPAGE ||
+ mePageKind == PK_NOTES ||
+ mePageKind == PK_HANDOUT ||
+ (GetShellType()!=ST_DRAW&&IsLayerModeActive()))
+ {
+ if (rSet.GetItemState(SID_DELETE_PAGE) == SFX_ITEM_AVAILABLE)
+ rSet.DisableItem(SID_DELETE_PAGE);
+ if (rSet.GetItemState(SID_DELETE_MASTER_PAGE)==SFX_ITEM_AVAILABLE)
+ rSet.DisableItem(SID_DELETE_MASTER_PAGE);
+ }
+ }
+
+ // darf der aktuelle Layer geloescht werden?
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DELETE_LAYER ) )
+ {
+ sal_uInt16 nCurrentLayer = GetLayerTabControl()->GetCurPageId();
+ const String& rName = GetLayerTabControl()->GetPageText(nCurrentLayer);
+
+ sal_Bool bDisableIt = !IsLayerModeActive();
+ bDisableIt |= (rName == String(SdResId(STR_LAYER_LAYOUT)));
+ bDisableIt |= (rName == String(SdResId(STR_LAYER_BCKGRND)));
+ bDisableIt |= (rName == String(SdResId(STR_LAYER_BCKGRNDOBJ)));
+ bDisableIt |= (rName == String(SdResId(STR_LAYER_CONTROLS)));
+ bDisableIt |= (rName == String(SdResId(STR_LAYER_MEASURELINES)));
+
+ if (bDisableIt)
+ {
+ rSet.DisableItem(SID_DELETE_LAYER);
+ rSet.DisableItem(SID_RENAMELAYER);
+ }
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CUT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_COPY ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTLINE_BULLET ))
+ {
+ OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
+
+ // Sonderbehandlung für SID_OUTLINE_BULLET wenn Objekte
+ // mit unterschiedlichen arten von NumBullet Items markiert
+ // sind
+ sal_Bool bHasOutliner = sal_False;
+ sal_Bool bHasOther = sal_False;
+ for(sal_uLong nNum = 0; nNum < nMarkCount; nNum++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(nNum)->GetMarkedSdrObj();
+ if( pObj->GetObjInventor() == SdrInventor )
+ {
+ if( pObj->GetObjIdentifier() == OBJ_OUTLINETEXT )
+ {
+ bHasOutliner = sal_True;
+ if(bHasOther)
+ break;
+ }
+ else
+ {
+ bHasOther = sal_True;
+ if(bHasOutliner)
+ break;
+ }
+ }
+ }
+
+ if( bHasOther && bHasOutliner )
+ rSet.DisableItem( SID_OUTLINE_BULLET );
+
+ if (pOlView)
+ {
+ if ( pOlView->GetSelected().Len() == 0 )
+ {
+ rSet.DisableItem( SID_CUT );
+ rSet.DisableItem( SID_COPY );
+ }
+ }
+
+ }
+
+ FuBullet::GetSlotState( rSet, this, GetViewFrame() );
+
+ if ( GetDocSh()->IsUIActive() )
+ {
+ rSet.DisableItem( SID_INSERT_OBJECT );
+ rSet.DisableItem( SID_INSERT_PLUGIN );
+ rSet.DisableItem( SID_INSERT_SOUND );
+ rSet.DisableItem( SID_INSERT_VIDEO );
+ rSet.DisableItem( SID_INSERT_FLOATINGFRAME );
+ rSet.DisableItem( SID_INSERT_MATH );
+ rSet.DisableItem( SID_INSERT_DIAGRAM );
+ rSet.DisableItem( SID_ATTR_TABLE );
+ rSet.DisableItem( SID_SIZE_REAL );
+ rSet.DisableItem( SID_SIZE_OPTIMAL );
+ rSet.DisableItem( SID_SIZE_ALL );
+ rSet.DisableItem( SID_SIZE_PAGE_WIDTH );
+ rSet.DisableItem( SID_SIZE_PAGE );
+ rSet.DisableItem( SID_DUPLICATE_PAGE );
+ rSet.DisableItem( SID_ZOOM_TOOLBOX );
+ }
+
+ // Zoom-Stati
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_IN ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_OUT )||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_PANNING ) )
+ {
+ if( GetActiveWindow()->GetZoom() <= GetActiveWindow()->GetMinZoom() || GetDocSh()->IsUIActive() )
+ {
+ rSet.DisableItem( SID_ZOOM_IN );
+ rSet.DisableItem( SID_ZOOM_PANNING );
+ }
+ if( GetActiveWindow()->GetZoom() >= GetActiveWindow()->GetMaxZoom() || GetDocSh()->IsUIActive() )
+ rSet.DisableItem( SID_ZOOM_OUT );
+ }
+
+ if (!mpZoomList->IsNextPossible())
+ {
+ rSet.DisableItem(SID_ZOOM_NEXT);
+ }
+ if (!mpZoomList->IsPreviousPossible())
+ {
+ rSet.DisableItem(SID_ZOOM_PREV);
+ }
+
+ // EditText aktiv
+ if (GetViewShellBase().GetViewShellManager()->GetShell(RID_DRAW_TEXT_TOOLBOX) != NULL)
+ {
+ sal_uInt16 nCurrentSId = SID_ATTR_CHAR;
+
+ if(HasCurrentFunction())
+ {
+ nCurrentSId = GetCurrentFunction()->GetSlotID();
+ }
+ if( nCurrentSId != SID_TEXT_FITTOSIZE &&
+ nCurrentSId != SID_TEXT_FITTOSIZE_VERTICAL &&
+ nCurrentSId != SID_ATTR_CHAR_VERTICAL )
+ nCurrentSId = SID_ATTR_CHAR;
+
+ rSet.Put( SfxBoolItem( nCurrentSId, sal_True ) );
+
+ // Kurzform von UpdateToolboxImages()
+ rSet.Put( TbxImageItem( SID_DRAWTBX_TEXT, nCurrentSId ) );
+ }
+
+ if ( GetDocSh()->IsReadOnly() )
+ {
+ rSet.DisableItem( SID_AUTOSPELL_CHECK );
+ }
+ else
+ {
+ if (GetDoc()->GetOnlineSpell())
+ {
+ rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_True));
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_False));
+ }
+ }
+
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+ String aActiveLayer = mpDrawView->GetActiveLayer();
+
+ if ( ( aActiveLayer.Len() != 0 && pPV && ( pPV->IsLayerLocked(aActiveLayer) ||
+ !pPV->IsLayerVisible(aActiveLayer) ) ) ||
+ SD_MOD()->GetWaterCan() )
+ {
+ rSet.DisableItem( SID_PASTE );
+ rSet.DisableItem( SID_PASTE_SPECIAL );
+ rSet.DisableItem( SID_CLIPBOARD_FORMAT_ITEMS );
+
+ rSet.DisableItem( SID_INSERT_FLD_DATE_FIX );
+ rSet.DisableItem( SID_INSERT_FLD_DATE_VAR );
+ rSet.DisableItem( SID_INSERT_FLD_TIME_FIX );
+ rSet.DisableItem( SID_INSERT_FLD_TIME_VAR );
+ rSet.DisableItem( SID_INSERT_FLD_AUTHOR );
+ rSet.DisableItem( SID_INSERT_FLD_PAGE );
+ rSet.DisableItem( SID_INSERT_FLD_PAGES );
+ rSet.DisableItem( SID_INSERT_FLD_FILE );
+
+ rSet.DisableItem( SID_INSERT_GRAPHIC );
+ rSet.DisableItem( SID_INSERT_AVMEDIA );
+ rSet.DisableItem( SID_INSERT_DIAGRAM );
+ rSet.DisableItem( SID_INSERT_OBJECT );
+ rSet.DisableItem( SID_INSERT_PLUGIN );
+ rSet.DisableItem( SID_INSERT_SOUND );
+ rSet.DisableItem( SID_INSERT_VIDEO );
+ rSet.DisableItem( SID_INSERT_FLOATINGFRAME );
+
+ rSet.DisableItem( SID_INSERT_MATH );
+ rSet.DisableItem( SID_INSERT_FRAME );
+ rSet.DisableItem( SID_INSERTFILE );
+ rSet.DisableItem( SID_ATTR_TABLE );
+ rSet.DisableItem( SID_COPYOBJECTS );
+
+ rSet.DisableItem( SID_SCAN );
+ rSet.DisableItem( SID_TWAIN_SELECT );
+ rSet.DisableItem( SID_TWAIN_TRANSFER );
+
+// rSet.DisableItem( SID_BEZIER_EDIT );
+ rSet.DisableItem( SID_GLUE_EDITMODE );
+ rSet.DisableItem( SID_OBJECT_ROTATE );
+ rSet.DisableItem( SID_OBJECT_SHEAR );
+ rSet.DisableItem( SID_OBJECT_MIRROR );
+ rSet.DisableItem( SID_OBJECT_CROP );
+ rSet.DisableItem( SID_ATTR_GRAF_CROP );
+ rSet.DisableItem( SID_OBJECT_TRANSPARENCE );
+ rSet.DisableItem( SID_OBJECT_GRADIENT );
+ rSet.DisableItem( SID_OBJECT_CROOK_ROTATE );
+ rSet.DisableItem( SID_OBJECT_CROOK_SLANT );
+ rSet.DisableItem( SID_OBJECT_CROOK_STRETCH );
+
+ // Alle objekterzeugenden Werkzeuge disablen
+ rSet.ClearItem( SID_ATTR_CHAR );
+ rSet.DisableItem( SID_ATTR_CHAR );
+ rSet.ClearItem( SID_ATTR_CHAR_VERTICAL );
+ rSet.DisableItem( SID_ATTR_CHAR_VERTICAL );
+ rSet.ClearItem(SID_DRAW_LINE);
+ rSet.DisableItem(SID_DRAW_LINE);
+ rSet.ClearItem(SID_DRAW_MEASURELINE);
+ rSet.DisableItem(SID_DRAW_MEASURELINE);
+ rSet.ClearItem(SID_DRAW_XLINE);
+ rSet.DisableItem(SID_DRAW_XLINE);
+ rSet.ClearItem( SID_LINE_ARROW_START );
+ rSet.DisableItem( SID_LINE_ARROW_START );
+ rSet.ClearItem( SID_LINE_ARROW_END );
+ rSet.DisableItem( SID_LINE_ARROW_END );
+ rSet.ClearItem( SID_LINE_ARROWS );
+ rSet.DisableItem( SID_LINE_ARROWS );
+ rSet.ClearItem( SID_LINE_ARROW_CIRCLE );
+ rSet.DisableItem( SID_LINE_ARROW_CIRCLE );
+ rSet.ClearItem( SID_LINE_CIRCLE_ARROW );
+ rSet.DisableItem( SID_LINE_CIRCLE_ARROW );
+ rSet.ClearItem( SID_LINE_ARROW_SQUARE );
+ rSet.DisableItem( SID_LINE_ARROW_SQUARE );
+ rSet.ClearItem( SID_LINE_SQUARE_ARROW );
+ rSet.DisableItem( SID_LINE_SQUARE_ARROW );
+
+ rSet.ClearItem(SID_DRAW_RECT);
+ rSet.DisableItem(SID_DRAW_RECT);
+ rSet.ClearItem(SID_DRAW_RECT_NOFILL);
+ rSet.DisableItem(SID_DRAW_RECT_NOFILL);
+ rSet.ClearItem(SID_DRAW_RECT_ROUND);
+ rSet.DisableItem(SID_DRAW_RECT_ROUND);
+ rSet.ClearItem(SID_DRAW_RECT_ROUND_NOFILL);
+ rSet.DisableItem(SID_DRAW_RECT_ROUND_NOFILL);
+ rSet.ClearItem(SID_DRAW_SQUARE);
+ rSet.DisableItem(SID_DRAW_SQUARE);
+ rSet.ClearItem(SID_DRAW_SQUARE_NOFILL);
+ rSet.DisableItem(SID_DRAW_SQUARE_NOFILL);
+ rSet.ClearItem(SID_DRAW_SQUARE_ROUND);
+ rSet.DisableItem(SID_DRAW_SQUARE_ROUND);
+ rSet.ClearItem(SID_DRAW_SQUARE_ROUND_NOFILL);
+ rSet.DisableItem(SID_DRAW_SQUARE_ROUND_NOFILL);
+ rSet.ClearItem(SID_DRAW_ELLIPSE);
+ rSet.DisableItem(SID_DRAW_ELLIPSE);
+ rSet.ClearItem(SID_DRAW_ELLIPSE_NOFILL);
+ rSet.DisableItem(SID_DRAW_ELLIPSE_NOFILL);
+ rSet.ClearItem(SID_DRAW_CIRCLE);
+ rSet.DisableItem(SID_DRAW_CIRCLE);
+ rSet.ClearItem(SID_DRAW_CIRCLE_NOFILL);
+ rSet.DisableItem(SID_DRAW_CIRCLE_NOFILL);
+ rSet.ClearItem(SID_DRAW_CAPTION);
+ rSet.DisableItem(SID_DRAW_CAPTION);
+ rSet.ClearItem(SID_DRAW_FONTWORK);
+ rSet.DisableItem(SID_DRAW_FONTWORK);
+ rSet.ClearItem(SID_DRAW_FONTWORK_VERTICAL);
+ rSet.DisableItem(SID_DRAW_FONTWORK_VERTICAL);
+ rSet.ClearItem(SID_DRAW_CAPTION_VERTICAL);
+ rSet.DisableItem(SID_DRAW_CAPTION_VERTICAL);
+ rSet.ClearItem(SID_TEXT_FITTOSIZE);
+ rSet.DisableItem(SID_TEXT_FITTOSIZE);
+ rSet.ClearItem(SID_TEXT_FITTOSIZE_VERTICAL);
+ rSet.DisableItem(SID_TEXT_FITTOSIZE_VERTICAL);
+ rSet.ClearItem(SID_TOOL_CONNECTOR);
+ rSet.DisableItem(SID_TOOL_CONNECTOR);
+ rSet.ClearItem(SID_CONNECTOR_ARROW_START);
+ rSet.DisableItem(SID_CONNECTOR_ARROW_START);
+ rSet.ClearItem(SID_CONNECTOR_ARROW_END);
+ rSet.DisableItem(SID_CONNECTOR_ARROW_END);
+ rSet.ClearItem(SID_CONNECTOR_ARROWS);
+ rSet.DisableItem(SID_CONNECTOR_ARROWS);
+ rSet.ClearItem(SID_CONNECTOR_CIRCLE_START);
+ rSet.DisableItem(SID_CONNECTOR_CIRCLE_START);
+ rSet.ClearItem(SID_CONNECTOR_CIRCLE_END);
+ rSet.DisableItem(SID_CONNECTOR_CIRCLE_END);
+ rSet.ClearItem(SID_CONNECTOR_CIRCLES);
+ rSet.DisableItem(SID_CONNECTOR_CIRCLES);
+ rSet.ClearItem(SID_CONNECTOR_LINE);
+ rSet.DisableItem(SID_CONNECTOR_LINE);
+ rSet.ClearItem(SID_CONNECTOR_LINE_ARROW_START);
+ rSet.DisableItem(SID_CONNECTOR_LINE_ARROW_START);
+ rSet.ClearItem(SID_CONNECTOR_LINE_ARROW_END);
+ rSet.DisableItem(SID_CONNECTOR_LINE_ARROW_END);
+ rSet.ClearItem(SID_CONNECTOR_LINE_ARROWS);
+ rSet.DisableItem(SID_CONNECTOR_LINE_ARROWS);
+ rSet.ClearItem(SID_CONNECTOR_LINE_CIRCLE_START);
+ rSet.DisableItem(SID_CONNECTOR_LINE_CIRCLE_START);
+ rSet.ClearItem(SID_CONNECTOR_LINE_CIRCLE_END);
+ rSet.DisableItem(SID_CONNECTOR_LINE_CIRCLE_END);
+ rSet.ClearItem(SID_CONNECTOR_LINE_CIRCLES);
+ rSet.DisableItem(SID_CONNECTOR_LINE_CIRCLES);
+ rSet.ClearItem(SID_CONNECTOR_CURVE);
+ rSet.DisableItem(SID_CONNECTOR_CURVE);
+ rSet.ClearItem(SID_CONNECTOR_CURVE_ARROW_START);
+ rSet.DisableItem(SID_CONNECTOR_CURVE_ARROW_START);
+ rSet.ClearItem(SID_CONNECTOR_CURVE_ARROW_END);
+ rSet.DisableItem(SID_CONNECTOR_CURVE_ARROW_END);
+ rSet.ClearItem(SID_CONNECTOR_CURVE_ARROWS);
+ rSet.DisableItem(SID_CONNECTOR_CURVE_ARROWS);
+ rSet.ClearItem(SID_CONNECTOR_CURVE_CIRCLE_START);
+ rSet.DisableItem(SID_CONNECTOR_CURVE_CIRCLE_START);
+ rSet.ClearItem(SID_CONNECTOR_CURVE_CIRCLE_END);
+ rSet.DisableItem(SID_CONNECTOR_CURVE_CIRCLE_END);
+ rSet.ClearItem(SID_CONNECTOR_CURVE_CIRCLES);
+ rSet.DisableItem(SID_CONNECTOR_CURVE_CIRCLES);
+ rSet.ClearItem(SID_CONNECTOR_LINES);
+ rSet.DisableItem(SID_CONNECTOR_LINES);
+ rSet.ClearItem(SID_CONNECTOR_LINES_ARROW_START);
+ rSet.DisableItem(SID_CONNECTOR_LINES_ARROW_START);
+ rSet.ClearItem(SID_CONNECTOR_LINES_ARROW_END);
+ rSet.DisableItem(SID_CONNECTOR_LINES_ARROW_END);
+ rSet.ClearItem(SID_CONNECTOR_LINES_ARROWS);
+ rSet.DisableItem(SID_CONNECTOR_LINES_ARROWS);
+ rSet.ClearItem(SID_CONNECTOR_LINES_CIRCLE_START);
+ rSet.DisableItem(SID_CONNECTOR_LINES_CIRCLE_START);
+ rSet.ClearItem(SID_CONNECTOR_LINES_CIRCLE_END);
+ rSet.DisableItem(SID_CONNECTOR_LINES_CIRCLE_END);
+ rSet.ClearItem(SID_CONNECTOR_LINES_CIRCLES);
+ rSet.DisableItem(SID_CONNECTOR_LINES_CIRCLES);
+ rSet.ClearItem(SID_DRAW_ARC);
+ rSet.DisableItem(SID_DRAW_ARC);
+ rSet.ClearItem(SID_DRAW_CIRCLEARC);
+ rSet.DisableItem(SID_DRAW_CIRCLEARC);
+ rSet.ClearItem(SID_DRAW_PIE);
+ rSet.DisableItem(SID_DRAW_PIE);
+ rSet.ClearItem(SID_DRAW_PIE_NOFILL);
+ rSet.DisableItem(SID_DRAW_PIE_NOFILL);
+ rSet.ClearItem(SID_DRAW_CIRCLEPIE);
+ rSet.DisableItem(SID_DRAW_CIRCLEPIE);
+ rSet.ClearItem(SID_DRAW_CIRCLEPIE_NOFILL);
+ rSet.DisableItem(SID_DRAW_CIRCLEPIE_NOFILL);
+ rSet.ClearItem(SID_DRAW_ELLIPSECUT);
+ rSet.DisableItem(SID_DRAW_ELLIPSECUT);
+ rSet.ClearItem(SID_DRAW_ELLIPSECUT_NOFILL);
+ rSet.DisableItem(SID_DRAW_ELLIPSECUT_NOFILL);
+ rSet.ClearItem(SID_DRAW_CIRCLECUT);
+ rSet.DisableItem(SID_DRAW_CIRCLECUT);
+ rSet.ClearItem(SID_DRAW_CIRCLECUT_NOFILL);
+ rSet.DisableItem(SID_DRAW_CIRCLECUT_NOFILL);
+ rSet.ClearItem(SID_DRAW_POLYGON);
+ rSet.DisableItem(SID_DRAW_POLYGON);
+ rSet.ClearItem(SID_DRAW_POLYGON_NOFILL);
+ rSet.DisableItem(SID_DRAW_POLYGON_NOFILL);
+ rSet.ClearItem(SID_DRAW_FREELINE);
+ rSet.DisableItem(SID_DRAW_FREELINE);
+ rSet.ClearItem(SID_DRAW_FREELINE_NOFILL);
+ rSet.DisableItem(SID_DRAW_FREELINE_NOFILL);
+ rSet.ClearItem(SID_DRAW_XPOLYGON);
+ rSet.DisableItem(SID_DRAW_XPOLYGON);
+ rSet.ClearItem(SID_DRAW_XPOLYGON_NOFILL);
+ rSet.DisableItem(SID_DRAW_XPOLYGON_NOFILL);
+ rSet.ClearItem(SID_DRAW_BEZIER_FILL);
+ rSet.DisableItem(SID_DRAW_BEZIER_FILL);
+ rSet.ClearItem(SID_DRAW_BEZIER_NOFILL);
+ rSet.DisableItem(SID_DRAW_BEZIER_NOFILL);
+ rSet.ClearItem(SID_3D_CUBE);
+ rSet.DisableItem(SID_3D_CUBE);
+ rSet.ClearItem(SID_3D_SHELL);
+ rSet.DisableItem(SID_3D_SHELL);
+ rSet.ClearItem(SID_3D_SPHERE);
+ rSet.DisableItem(SID_3D_SPHERE);
+ rSet.ClearItem(SID_3D_HALF_SPHERE);
+ rSet.DisableItem(SID_3D_HALF_SPHERE);
+ rSet.ClearItem(SID_3D_CYLINDER);
+ rSet.DisableItem(SID_3D_CYLINDER);
+ rSet.ClearItem(SID_3D_CONE);
+ rSet.DisableItem(SID_3D_CONE);
+ rSet.ClearItem(SID_3D_TORUS);
+ rSet.DisableItem(SID_3D_TORUS);
+ rSet.ClearItem(SID_3D_PYRAMID);
+ rSet.DisableItem(SID_3D_PYRAMID);
+ }
+
+ // Sind die Module verfuegbar?
+
+ if (!SvtModuleOptions().IsCalc())
+ {
+ // remove menu entry if module is not available
+ rSet.Put( SfxVisibilityItem( SID_ATTR_TABLE, sal_False ) );
+ }
+ if (!SvtModuleOptions().IsChart())
+ {
+ rSet.DisableItem( SID_INSERT_DIAGRAM );
+ }
+#ifdef STARIMAGE_AVAILABLE
+ if (!(pApp->HasFeature(SFX_FEATURE_SIMAGE)))
+ {
+ rSet.DisableItem( SID_INSERT_IMAGE );
+ }
+#endif
+ if (!SvtModuleOptions().IsMath())
+ {
+ rSet.DisableItem( SID_INSERT_MATH );
+ }
+
+ rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if( (xSlideshow.is() && xSlideshow->isRunning() && (xSlideshow->getAnimationMode() != ANIMATIONMODE_PREVIEW) ) || GetDocSh()->IsPreview() )
+ {
+ // Eigene Slots
+ rSet.DisableItem( SID_PRESENTATION );
+ rSet.DisableItem( SID_ZOOM_IN );
+ rSet.DisableItem( SID_ZOOM_OUT );
+ rSet.DisableItem( SID_ZOOM_PANNING );
+ rSet.DisableItem( SID_ZOOM_NEXT );
+ rSet.DisableItem( SID_ZOOM_PREV );
+ rSet.DisableItem( SID_SIZE_REAL );
+ rSet.DisableItem( SID_SIZE_OPTIMAL );
+ rSet.DisableItem( SID_SIZE_ALL );
+ rSet.DisableItem( SID_SIZE_PAGE_WIDTH );
+ rSet.DisableItem( SID_SIZE_PAGE );
+ rSet.DisableItem( SID_INSERTPAGE );
+ rSet.DisableItem( SID_DUPLICATE_PAGE );
+ rSet.DisableItem( SID_MODIFYPAGE );
+ rSet.DisableItem( SID_RENAMEPAGE );
+ rSet.DisableItem( SID_RENAMEPAGE_QUICK );
+ rSet.DisableItem( SID_DELETE_PAGE );
+ rSet.DisableItem( SID_PAGESETUP );
+
+ if( xSlideshow.is() && xSlideshow->isRunning() )
+ {
+ rSet.ClearItem(SID_OBJECT_ALIGN);
+ rSet.ClearItem(SID_ZOOM_TOOLBOX);
+ rSet.ClearItem(SID_OBJECT_CHOOSE_MODE);
+ rSet.ClearItem(SID_DRAWTBX_TEXT);
+ rSet.ClearItem(SID_DRAWTBX_RECTANGLES);
+ rSet.ClearItem(SID_DRAWTBX_ELLIPSES);
+ rSet.ClearItem(SID_DRAWTBX_LINES);
+ rSet.ClearItem(SID_DRAWTBX_ARROWS);
+ rSet.ClearItem(SID_DRAWTBX_3D_OBJECTS);
+ rSet.ClearItem(SID_DRAWTBX_CONNECTORS);
+ rSet.ClearItem(SID_OBJECT_CHOOSE_MODE );
+ rSet.ClearItem(SID_DRAWTBX_INSERT);
+ rSet.ClearItem(SID_INSERTFILE);
+ rSet.ClearItem(SID_OBJECT_ROTATE);
+ rSet.ClearItem(SID_OBJECT_ALIGN);
+ rSet.ClearItem(SID_POSITION);
+ rSet.ClearItem(SID_FM_CONFIG);
+ rSet.ClearItem(SID_ANIMATION_EFFECTS);
+ rSet.ClearItem(SID_ANIMATION_OBJECTS);
+ rSet.ClearItem(SID_3D_WIN);
+
+ rSet.DisableItem(SID_OBJECT_ALIGN);
+ rSet.DisableItem(SID_ZOOM_TOOLBOX);
+ rSet.DisableItem(SID_OBJECT_CHOOSE_MODE);
+ rSet.DisableItem(SID_DRAWTBX_TEXT);
+ rSet.DisableItem(SID_DRAWTBX_RECTANGLES);
+ rSet.DisableItem(SID_DRAWTBX_ELLIPSES);
+ rSet.DisableItem(SID_DRAWTBX_LINES);
+ rSet.DisableItem(SID_DRAWTBX_ARROWS);
+ rSet.DisableItem(SID_DRAWTBX_3D_OBJECTS);
+ rSet.DisableItem(SID_DRAWTBX_CONNECTORS);
+ rSet.DisableItem(SID_OBJECT_CHOOSE_MODE );
+ rSet.DisableItem(SID_DRAWTBX_INSERT);
+ rSet.DisableItem(SID_INSERTFILE);
+ rSet.DisableItem(SID_OBJECT_ROTATE);
+ rSet.DisableItem(SID_OBJECT_ALIGN);
+ rSet.DisableItem(SID_POSITION);
+ rSet.DisableItem(SID_FM_CONFIG);
+ rSet.DisableItem(SID_ANIMATION_EFFECTS);
+ rSet.DisableItem(SID_ANIMATION_OBJECTS);
+ rSet.DisableItem(SID_3D_WIN);
+ }
+ }
+
+ // #i102735# discussed with CL: removed for performance reasons
+ #if 0
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_SOUND ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_INSERT_VIDEO ) )
+ {
+ ///////////////////////////////////////////////////////////////////////
+ // Menuoption : Insert->Object->Sound and Insert->Object->Video
+ // diable, if there isn't installed any appropriate plugin
+ //
+ if (!SvxPluginFileDlg::IsAvailable (SID_INSERT_SOUND))
+ rSet.DisableItem (SID_INSERT_SOUND);
+ if (!SvxPluginFileDlg::IsAvailable (SID_INSERT_VIDEO))
+ rSet.DisableItem (SID_INSERT_VIDEO);
+ }
+ #endif
+
+ ///////////////////////////////////////////////////////////////////////
+ // Menuoption: Change->Convert->To Bitmap, Change->Convert->To Metafile
+ // disable, if there only Bitmap or Metafiles marked
+ // Menuoption: Format->Area, Format->Line
+ // disabled, if the marked objects not able to handle
+ // these attributes
+ //
+
+ bool bSingleGraphicSelected = false;
+
+ if (!mpDrawView->AreObjectsMarked())
+ {
+ rSet.DisableItem (SID_CONVERT_TO_METAFILE);
+ rSet.DisableItem (SID_CONVERT_TO_BITMAP);
+ }
+ else
+ {
+ // get marklist
+ SdrMarkList aMarkList = mpDrawView->GetMarkedObjectList();
+
+ sal_Bool bFoundBitmap = sal_False;
+ sal_Bool bFoundMetafile = sal_False;
+ sal_Bool bFoundObjNoLine = sal_False;
+ sal_Bool bFoundObjNoArea = sal_False;
+ sal_Bool bFoundNoGraphicObj = sal_False;
+ sal_Bool bFoundAny = sal_False;
+ bool bFoundTable = false;
+
+// const int nMarkCount = (int) aMarkList.GetMarkCount();
+ for (sal_uLong i=0; i < nMarkCount && !bFoundAny; i++)
+ {
+ SdrObject* pObj= aMarkList.GetMark(i)->GetMarkedSdrObj();
+ sal_uInt16 nId = pObj->GetObjIdentifier();
+ sal_uInt32 nInv = pObj->GetObjInventor();
+
+ if(nInv == SdrInventor)
+ {
+ // 2D objects
+ switch( nId )
+ {
+ case OBJ_PATHLINE :
+ case OBJ_PLIN :
+ case OBJ_LINE:
+ case OBJ_FREELINE :
+ case OBJ_EDGE:
+ case OBJ_CARC :
+ bFoundObjNoArea = sal_True;
+ bFoundNoGraphicObj = sal_True;
+ break;
+ case OBJ_OLE2 :
+ bFoundObjNoLine = sal_True;
+ bFoundObjNoArea = sal_True;
+ bFoundNoGraphicObj = sal_True;
+ break;
+ case OBJ_GRAF :
+ bSingleGraphicSelected = nMarkCount == 1;
+ switch ( ((SdrGrafObj*)pObj)->GetGraphicType() )
+ {
+ case GRAPHIC_BITMAP :
+ bFoundBitmap = sal_True;
+ break;
+ case GRAPHIC_GDIMETAFILE :
+ bFoundMetafile = sal_True;
+ break;
+ default:
+ break;
+ }
+
+ // #i25616# bFoundObjNoLine = sal_True;
+ // #i25616# bFoundObjNoArea = sal_True;
+ break;
+ case OBJ_TABLE:
+ bFoundTable = true;
+ break;
+ default :
+ bFoundAny = sal_True;
+ }
+ }
+ else if(nInv == E3dInventor)
+ {
+ // 3D objects
+ bFoundAny = sal_True;
+ }
+ }
+
+ if( bFoundTable )
+ rSet.DisableItem( SID_ATTRIBUTES_LINE );
+
+ if (!bFoundAny)
+ {
+ // Disable menuitem for area-dialog
+ if( bFoundObjNoArea ) // #i25616#
+ rSet.DisableItem( SID_ATTRIBUTES_AREA );
+
+ // Disable menuitem for line-dialog
+ if( bFoundObjNoLine )
+ rSet.DisableItem( SID_ATTRIBUTES_LINE );
+
+ if( bFoundBitmap && !bFoundMetafile && !bFoundNoGraphicObj ) // only Bitmaps marked
+ rSet.DisableItem( SID_CONVERT_TO_BITMAP );
+ else if( !bFoundBitmap && bFoundMetafile && !bFoundNoGraphicObj ) // only Metafiles marked
+ rSet.DisableItem( SID_CONVERT_TO_METAFILE );
+ else if( !bFoundBitmap && !bFoundMetafile && !bFoundNoGraphicObj ) // nothing to do
+ {
+ rSet.DisableItem( SID_CONVERT_TO_BITMAP );
+ rSet.DisableItem( SID_CONVERT_TO_METAFILE );
+ }
+ }
+ }
+
+ if( !bSingleGraphicSelected )
+ {
+ rSet.DisableItem (SID_OBJECT_CROP);
+ rSet.DisableItem (SID_ATTR_GRAF_CROP);
+ }
+
+ // #96090# moved SID_UNDO to ViewShell::GetMenuState()
+ // #96090# moved SID_REDO to ViewShell::GetMenuState()
+ // #96090# moved SID_GETUNDOSTRINGS to ViewShell::GetMenuState()
+ // #96090# moved SID_GETREDOSTRINGS to ViewShell::GetMenuState()
+
+ ///////////////////////////////////////////////////////////////////////
+ // Menuoption: Edit->Hyperlink
+ // Disable, if there is no hyperlink
+ //
+ sal_Bool bDisableEditHyperlink = sal_True;
+ if( mpDrawView->AreObjectsMarked() && ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 1 ) )
+ {
+ if( mpDrawView->IsTextEdit() )
+ {
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+ if (pOLV)
+ {
+ const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ ESelection aSel = pOLV->GetSelection();
+ if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( pField->ISA(SvxURLField) )
+ bDisableEditHyperlink = sal_False;
+ }
+ }
+ }
+ }
+ else
+ {
+ SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj());
+
+ if ( pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor() )
+ {
+ uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel() );
+ if( xControlModel.is() )
+ {
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY );
+ if( xPropSet.is() )
+ {
+ uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo() );
+ if( xPropInfo.is() && xPropInfo->hasPropertyByName(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL"))))
+ {
+ bDisableEditHyperlink = sal_False;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //highlight selected custom shape
+ {
+ sal_uInt16 nCurrentSId = 0;
+ if(HasCurrentFunction())
+ nCurrentSId = GetCurrentFunction()->GetSlotID();
+
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_BASIC ) )
+ rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_BASIC, SID_DRAWTBX_CS_BASIC == nCurrentSId ));
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_SYMBOL ) )
+ rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_SYMBOL, SID_DRAWTBX_CS_SYMBOL == nCurrentSId ));
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_ARROW ) )
+ rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_ARROW, SID_DRAWTBX_CS_ARROW == nCurrentSId ));
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_FLOWCHART ) )
+ rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_FLOWCHART, SID_DRAWTBX_CS_FLOWCHART == nCurrentSId ));
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_CALLOUT ) )
+ rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_CALLOUT,SID_DRAWTBX_CS_CALLOUT == nCurrentSId ));
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DRAWTBX_CS_STAR ) )
+ rSet.Put(SfxBoolItem(SID_DRAWTBX_CS_STAR, SID_DRAWTBX_CS_STAR == nCurrentSId ));
+ }
+
+ if ( bDisableEditHyperlink || GetDocSh()->IsReadOnly() )
+ rSet.DisableItem( SID_EDIT_HYPERLINK );
+
+ if ( bDisableEditHyperlink )
+ rSet.DisableItem( SID_OPEN_HYPERLINK );
+
+#if defined WNT || defined UNX
+ if( !mxScannerManager.is() )
+ {
+ rSet.DisableItem( SID_TWAIN_SELECT );
+ rSet.DisableItem( SID_TWAIN_TRANSFER );
+ }
+#endif
+
+ // Set the state of two entries in the 'Slide' context sub-menu
+ // concerning the visibility of master page background and master page
+ // shapes.
+ if (rSet.GetItemState(SID_DISPLAY_MASTER_BACKGROUND) == SFX_ITEM_AVAILABLE
+ || rSet.GetItemState(SID_DISPLAY_MASTER_OBJECTS) == SFX_ITEM_AVAILABLE)
+ {
+ SdPage* pPage = GetActualPage();
+ if (pPage != NULL
+ && GetDoc() != NULL)
+ {
+ SetOfByte aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
+ SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
+ sal_uInt8 aBackgroundId = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
+ sal_uInt8 aObjectId = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
+ rSet.Put(SfxBoolItem(SID_DISPLAY_MASTER_BACKGROUND,
+ aVisibleLayers.IsSet(aBackgroundId)));
+ rSet.Put(SfxBoolItem(SID_DISPLAY_MASTER_OBJECTS,
+ aVisibleLayers.IsSet(aObjectId)));
+ }
+ }
+
+ GetModeSwitchingMenuState (rSet);
+}
+
+void DrawViewShell::GetModeSwitchingMenuState (SfxItemSet &rSet)
+{
+ //draview
+ rSet.Put(SfxBoolItem(SID_DIAMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_OUTLINEMODE, sal_False));
+ if (mePageKind == PK_NOTES)
+ {
+ rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_True));
+ rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_False));
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_True));
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_True));
+ rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_False));
+ }
+
+ // #101976# Removed [GetDocSh()->GetCurrentFunction() ||] from the following
+ // clause because the current function of the docshell can only be
+ // search and replace or spell checking and in that case switching the
+ // view mode is allowed.
+ const bool bIsRunning = SlideShow::IsRunning(GetViewShellBase());
+
+ if (GetViewFrame()->GetFrame().IsInPlace() || bIsRunning)
+ {
+ if ( !GetViewFrame()->GetFrame().IsInPlace() )
+ {
+ rSet.ClearItem( SID_DRAWINGMODE );
+ rSet.DisableItem( SID_DRAWINGMODE );
+ }
+
+ rSet.ClearItem( SID_NOTESMODE );
+ rSet.DisableItem( SID_NOTESMODE );
+
+ rSet.ClearItem( SID_HANDOUTMODE );
+ rSet.DisableItem( SID_HANDOUTMODE );
+
+ rSet.ClearItem( SID_OUTLINEMODE );
+ rSet.DisableItem( SID_OUTLINEMODE );
+
+ rSet.ClearItem( SID_DIAMODE );
+ rSet.DisableItem( SID_DIAMODE );
+ }
+
+ if (GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
+ {
+ // Outplace-Edit: Kein Umschalten erlauben
+ rSet.ClearItem( SID_OUTLINEMODE );
+ rSet.DisableItem( SID_OUTLINEMODE );
+
+ rSet.ClearItem( SID_DIAMODE );
+ rSet.DisableItem( SID_DIAMODE );
+
+ rSet.ClearItem( SID_NOTESMODE );
+ rSet.DisableItem( SID_NOTESMODE );
+
+ rSet.ClearItem( SID_HANDOUTMODE );
+ rSet.DisableItem( SID_HANDOUTMODE );
+ }
+
+ svx::ExtrusionBar::getState( mpDrawView, rSet );
+ svx::FontworkBar::getState( mpDrawView, rSet );
+}
+
+
+
+void DrawViewShell::GetState (SfxItemSet& rSet)
+{
+ // Iterate over all requested items in the set.
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_SEARCH_ITEM:
+ case SID_SEARCH_OPTIONS:
+ // Forward this request to the the common (old) code of the
+ // document shell.
+ GetDocSh()->GetState (rSet);
+ break;
+ default:
+ OSL_TRACE ("DrawViewShell::GetState(): can not handle which id %d", nWhich);
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+
+
+void DrawViewShell::Execute (SfxRequest& rReq)
+{
+ if(SlideShow::IsRunning(GetViewShellBase()))
+ {
+ // Do not execute anything during a native slide show.
+ return;
+ }
+
+ switch (rReq.GetSlot())
+ {
+ case SID_SEARCH_ITEM:
+ // Forward this request to the the common (old) code of the
+ // document shell.
+ GetDocSh()->Execute (rReq);
+ break;
+
+ case SID_SPELL_DIALOG:
+ {
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ if (rReq.GetArgs() != NULL)
+ pViewFrame->SetChildWindow (SID_SPELL_DIALOG,
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(SID_SPELL_DIALOG))).GetValue());
+ else
+ pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG);
+
+ pViewFrame->GetBindings().Invalidate(SID_SPELL_DIALOG);
+ rReq.Ignore ();
+ }
+ break;
+
+ default:
+ OSL_TRACE ("DrawViewShell::Execute(): can not handle slot %d", rReq.GetSlot());
+ break;
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviews8.cxx b/sd/source/ui/view/drviews8.cxx
new file mode 100755
index 000000000000..c4f8968f9ad9
--- /dev/null
+++ b/sd/source/ui/view/drviews8.cxx
@@ -0,0 +1,557 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+
+#include "ViewShellHint.hxx"
+
+#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
+#include <toolkit/unohlp.hxx>
+#endif
+#include <sfx2/dispatch.hxx>
+#ifndef _SVXIDS_HXX
+#include <svx/svxids.hrc>
+#endif
+#include <vcl/msgbox.hxx>
+#include <svx/svddef.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdpagv.hxx>
+
+#include "app.hrc"
+#include "strings.hrc"
+
+#include "misc.hxx"
+#include "fuzoom.hxx"
+#include "fudspord.hxx"
+#include "futransf.hxx"
+#include "fuline.hxx"
+#include "fuarea.hxx"
+#include "fuchar.hxx"
+#include "fuparagr.hxx"
+#include "fubullet.hxx"
+#include "futempl.hxx"
+#include "fuinsert.hxx"
+#include "fuprlout.hxx"
+#include "fupage.hxx"
+#ifndef SD_FU_OBJECT_ANIMATION_PARAMETERS_HXX
+#include "fuoaprms.hxx"
+#endif
+#include "fucopy.hxx"
+#ifndef SD_FU_LINE_END_HXX
+#include "fulinend.hxx"
+#endif
+#include "fusnapln.hxx"
+#include "fuolbull.hxx"
+#include "fuinsfil.hxx"
+#include "fulink.hxx"
+#include "futhes.hxx"
+#include "futxtatt.hxx"
+#include "fumeasur.hxx"
+#include "fuconnct.hxx"
+#include "fumorph.hxx"
+#include "fuvect.hxx"
+#include "sdresid.hxx"
+#include "Window.hxx"
+#include "drawview.hxx"
+#include "zoomlist.hxx"
+#include <vos/mutex.hxx>
+#include <vcl/salbtype.hxx> // FRound
+#include <vcl/svapp.hxx>
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* SfxRequests fuer temporaere Funktionen
+|*
+\************************************************************************/
+
+void DrawViewShell::FuTemp01(SfxRequest& rReq)
+{
+ switch(rReq.GetSlot())
+ {
+ case SID_ATTRIBUTES_LINE: // BASIC
+ {
+ SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_ATTRIBUTES_AREA: // BASIC
+ {
+ SetCurrentFunction( FuArea::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_ATTR_TRANSFORM:
+ {
+ SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Invalidate(SID_RULER_OBJECT);
+ Cancel();
+ }
+ break;
+
+ case SID_CHAR_DLG: // BASIC
+ {
+ SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_PARA_DLG:
+ {
+ SetCurrentFunction( FuParagraph::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_OUTLINE_BULLET:
+ {
+ SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case FN_INSERT_SOFT_HYPHEN:
+ case FN_INSERT_HARDHYPHEN:
+ case FN_INSERT_HARD_SPACE:
+ case SID_INSERT_RLM :
+ case SID_INSERT_LRM :
+ case SID_INSERT_ZWNBSP :
+ case SID_INSERT_ZWSP:
+ case SID_CHARMAP:
+ {
+ SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_PRESENTATION_LAYOUT:
+ {
+ SetCurrentFunction( FuPresentationLayout::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+ Cancel();
+ }
+ break;
+
+ case SID_PASTE_SPECIAL:
+ {
+ SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_INSERT_GRAPHIC:
+ {
+ SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Ignore ();
+ Invalidate(SID_DRAWTBX_INSERT);
+ }
+ break;
+
+ case SID_INSERT_AVMEDIA:
+ {
+ SetCurrentFunction( FuInsertAVMedia::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+
+ Cancel();
+ rReq.Ignore ();
+
+ Invalidate(SID_DRAWTBX_INSERT);
+ }
+ break;
+
+ case SID_INSERT_OBJECT:
+ case SID_INSERT_PLUGIN:
+ case SID_INSERT_SOUND:
+ case SID_INSERT_VIDEO:
+ case SID_INSERT_FLOATINGFRAME:
+ case SID_INSERT_MATH:
+ case SID_INSERT_DIAGRAM:
+ case SID_ATTR_TABLE:
+ {
+ SetCurrentFunction( FuInsertOLE::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+
+ Cancel();
+ rReq.Ignore ();
+
+ Invalidate(SID_DRAWTBX_INSERT);
+ }
+ break;
+
+ case SID_COPYOBJECTS:
+ {
+ if ( mpDrawView->IsPresObjSelected(sal_False, sal_True) )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ SetCurrentFunction( FuCopy::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ }
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_INSERTFILE: // BASIC
+ {
+ Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
+ SetCurrentFunction( FuInsertFile::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
+ Cancel();
+ rReq.Done ();
+
+ Invalidate(SID_DRAWTBX_INSERT);
+ }
+ break;
+
+ case SID_SELECT_BACKGROUND:
+ case SID_PAGESETUP: // BASIC ??
+ {
+ SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Ignore (); // es werden eigenstaendige macros generiert !!
+ }
+ break;
+
+ case SID_ZOOM_OUT:
+ case SID_ZOOM_PANNING:
+ {
+ mbZoomOnPage = sal_False;
+ SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+ // Beendet sich selbst, kein Cancel() notwendig!
+ Invalidate( SID_ZOOM_TOOLBOX );
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_BEFORE_OBJ:
+ case SID_BEHIND_OBJ:
+ {
+ SetCurrentFunction( FuDisplayOrder::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+ Invalidate( SID_POSITION );
+ rReq.Ignore ();
+ // Beendet sich selbst, kein Cancel() notwendig!
+ }
+ break;
+
+ case SID_REVERSE_ORDER: // BASIC
+ {
+ mpDrawView->ReverseOrderOfMarked();
+ Invalidate( SID_POSITION );
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_ANIMATION_EFFECTS:
+ {
+ SetCurrentFunction( FuObjectAnimationParameters::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+ Cancel();
+ }
+ break;
+
+ case SID_LINEEND_POLYGON:
+ {
+ SetCurrentFunction( FuLineEnd::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_CAPTUREPOINT:
+ // negative Werte um Aufruf aus Menue zu signalisieren
+ maMousePos = Point(-1,-1);
+ case SID_SET_SNAPITEM:
+ {
+ SetCurrentFunction( FuSnapLine::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+ Cancel();
+ }
+ break;
+
+ case SID_MANAGE_LINKS:
+ {
+ SetCurrentFunction( FuLink::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_THESAURUS:
+ {
+ SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_TEXTATTR_DLG:
+ {
+ SetCurrentFunction( FuTextAttrDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_MEASURE_DLG:
+ {
+ SetCurrentFunction( FuMeasureDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_CONNECTION_DLG:
+ {
+ SetCurrentFunction( FuConnectionDlg::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_CONNECTION_NEW_ROUTING:
+ {
+ SfxItemSet aDefAttr( GetPool(), SDRATTR_EDGELINE1DELTA, SDRATTR_EDGELINE3DELTA );
+ GetView()->SetAttributes( aDefAttr, sal_True ); // (ReplaceAll)
+
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_TWAIN_SELECT:
+ {
+ sal_Bool bDone = sal_False;
+
+ if( mxScannerManager.is() )
+ {
+ try
+ {
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::scanner::ScannerContext >
+ aContexts( mxScannerManager->getAvailableScanners() );
+
+ if( aContexts.getLength() )
+ {
+ ::com::sun::star::scanner::ScannerContext aContext( aContexts.getConstArray()[ 0 ] );
+ bDone = mxScannerManager->configureScanner( aContext );
+ }
+ }
+ catch(...)
+ {
+ }
+ }
+
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_TWAIN_TRANSFER:
+ {
+ sal_Bool bDone = sal_False;
+
+ if( mxScannerManager.is() )
+ {
+ try
+ {
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::scanner::ScannerContext > aContexts( mxScannerManager->getAvailableScanners() );
+
+ if( aContexts.getLength() )
+ {
+ mxScannerManager->startScan( aContexts.getConstArray()[ 0 ], mxScannerListener );
+ bDone = sal_True;
+ }
+ }
+ catch( ... )
+ {
+ }
+ }
+
+ if( !bDone )
+ {
+#ifndef UNX
+ const sal_uInt16 nId = STR_TWAIN_NO_SOURCE;
+#else
+ const sal_uInt16 nId = STR_TWAIN_NO_SOURCE_UNX;
+#endif
+
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String( SdResId( nId ) ) ).Execute();
+ }
+ else
+ {
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_TWAIN_SELECT );
+ rBindings.Invalidate( SID_TWAIN_TRANSFER );
+ }
+
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_POLYGON_MORPHING:
+ {
+ SetCurrentFunction( FuMorph::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_VECTORIZE:
+ {
+ SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ default:
+ {
+ // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
+ // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp01 (drviews8),
+ // FuTemp02 (drviewsb) gewandert.
+ FuTemp02(rReq);
+ }
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* Scanner-Event
+|*
+\************************************************************************/
+
+void DrawViewShell::ScannerEvent( const ::com::sun::star::lang::EventObject& )
+{
+ if( mxScannerManager.is() )
+ {
+ const ::com::sun::star::scanner::ScannerContext aContext( mxScannerManager->getAvailableScanners().getConstArray()[ 0 ] );
+ const ::com::sun::star::scanner::ScanError eError = mxScannerManager->getError( aContext );
+
+ if( ::com::sun::star::scanner::ScanError_ScanErrorNone == eError )
+ {
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap > xBitmap( mxScannerManager->getBitmap( aContext ) );
+
+ if( xBitmap.is() )
+ {
+ const BitmapEx aScanBmp( VCLUnoHelper::GetBitmap( xBitmap ) );
+
+ if( !!aScanBmp )
+ {
+ const ::vos::OGuard aGuard( Application::GetSolarMutex() );
+ SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage();
+ Size aBmpSize( aScanBmp.GetPrefSize() ), aPageSize( pPage->GetSize() );
+ const MapMode aMap100( MAP_100TH_MM );
+
+ if( !aBmpSize.Width() || !aBmpSize.Height() )
+ aBmpSize = aScanBmp.GetSizePixel();
+
+ if( aScanBmp.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
+ aBmpSize = GetActiveWindow()->PixelToLogic( aBmpSize, aMap100 );
+ else
+ aBmpSize = OutputDevice::LogicToLogic( aBmpSize, aScanBmp.GetPrefMapMode(), aMap100 );
+
+ aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
+ aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
+
+ if( ( ( aBmpSize.Height() > aPageSize.Height() ) || ( aBmpSize.Width() > aPageSize.Width() ) ) && aBmpSize.Height() && aPageSize.Height() )
+ {
+ double fGrfWH = (double) aBmpSize.Width() / aBmpSize.Height();
+ double fWinWH = (double) aPageSize.Width() / aPageSize.Height();
+
+ if( fGrfWH < fWinWH )
+ {
+ aBmpSize.Width() = FRound( aPageSize.Height() * fGrfWH );
+ aBmpSize.Height()= aPageSize.Height();
+ }
+ else if( fGrfWH > 0.F )
+ {
+ aBmpSize.Width() = aPageSize.Width();
+ aBmpSize.Height()= FRound( aPageSize.Width() / fGrfWH );
+ }
+ }
+
+ Point aPnt ( ( aPageSize.Width() - aBmpSize.Width() ) >> 1, ( aPageSize.Height() - aBmpSize.Height() ) >> 1 );
+ aPnt += Point( pPage->GetLftBorder(), pPage->GetUppBorder() );
+ Rectangle aRect( aPnt, aBmpSize );
+ SdrGrafObj* pGrafObj = NULL;
+ sal_Bool bInsertNewObject = sal_True;
+
+ if( GetView()->AreObjectsMarked() )
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ if( pObj->ISA( SdrGrafObj ) )
+ {
+ pGrafObj = static_cast< SdrGrafObj* >( pObj );
+
+ if( pGrafObj->IsEmptyPresObj() )
+ {
+ bInsertNewObject = sal_False;
+ pGrafObj->SetEmptyPresObj(sal_False);
+ pGrafObj->SetOutlinerParaObject(NULL);
+ pGrafObj->SetGraphic( Graphic( aScanBmp ) );
+ }
+ }
+ }
+ }
+
+ if( bInsertNewObject )
+ {
+ pGrafObj = new SdrGrafObj( Graphic( aScanBmp ), aRect );
+ SdrPageView* pPV = GetView()->GetSdrPageView();
+ GetView()->InsertObjectAtView( pGrafObj, *pPV, SDRINSERT_SETDEFLAYER );
+ }
+ }
+ }
+ }
+ }
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_TWAIN_SELECT );
+ rBindings.Invalidate( SID_TWAIN_TRANSFER );
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx
new file mode 100755
index 000000000000..9c0def97a17d
--- /dev/null
+++ b/sd/source/ui/view/drviews9.cxx
@@ -0,0 +1,881 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include <vcl/wrkwin.hxx>
+#include <svx/xgrad.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/xlnwtit.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xflhtit.hxx>
+#include <svx/xflgrit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xlnwtit.hxx>
+#include <sfx2/bindings.hxx>
+
+#ifndef _SFX_DISPATCH_HXX //autogen
+#include <sfx2/dispatch.hxx>
+#endif
+#include <svl/intitem.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <svl/stritem.hxx>
+#ifndef _SVXIDS_HXX
+#include <svx/svxids.hrc>
+#endif
+#include <svx/xtable.hxx>
+#include <svx/gallery.hxx>
+#include <vcl/graph.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <sot/storage.hxx>
+#include <svl/whiter.hxx>
+#include <basic/sbstar.hxx>
+
+#include <sfx2/viewfrm.hxx>
+
+
+#include "app.hrc"
+#include "strings.hrc"
+#include "Window.hxx"
+#include "drawdoc.hxx"
+#include "drawview.hxx"
+#include "DrawDocShell.hxx"
+#include "sdresid.hxx"
+#include "fupoor.hxx"
+
+namespace sd {
+
+#ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
+#define SO2_DECL_SVINPLACEOBJECT_DEFINED
+SO2_DECL_REF(SvInPlaceObject)
+#endif
+#ifndef SO2_DECL_SVSTORAGE_DEFINED
+#define SO2_DECL_SVSTORAGE_DEFINED
+SO2_DECL_REF(SvStorage)
+#endif
+
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Gallery bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecGallery(SfxRequest& rReq)
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if(HasCurrentFunction(SID_PRESENTATION))
+ return;
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if ( pArgs )
+ {
+ const sal_uInt32 nFormats = ( (SfxUInt32Item&) pArgs->Get( SID_GALLERY_FORMATS ) ).GetValue();
+ GalleryExplorer* pGal = SVX_GALLERY();
+
+ if ( pGal )
+ {
+ GetDocSh()->SetWaitCursor( sal_True );
+
+ // Graphik einfuegen
+ if (nFormats & SGA_FORMAT_GRAPHIC)
+ {
+ Graphic aGraphic = pGal->GetGraphic();
+
+ // Ggf. Groesse reduzieren
+ Window aWindow (GetActiveWindow());
+ aWindow.SetMapMode(aGraphic.GetPrefMapMode());
+ Size aSizePix = aWindow.LogicToPixel(aGraphic.GetPrefSize());
+ aWindow.SetMapMode( MapMode(MAP_100TH_MM) );
+ Size aSize = aWindow.PixelToLogic(aSizePix);
+
+ // Groesse ggf. auf Seitengroesse begrenzen
+ SdrPage* pPage = mpDrawView->GetSdrPageView()->GetPage();
+ Size aPageSize = pPage->GetSize();
+ aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
+ aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
+
+
+ // Falls Grafik zu gross, wird die Grafik
+ // in die Seite eingepasst
+ if ( ( ( aSize.Height() > aPageSize.Height() ) || ( aSize.Width() > aPageSize.Width() ) ) &&
+ aSize.Height() && aPageSize.Height() )
+ {
+ float fGrfWH = (float)aSize.Width() /
+ (float)aSize.Height();
+ float fWinWH = (float)aPageSize.Width() /
+ (float)aPageSize.Height();
+
+ // Grafik an Pagesize anpassen (skaliert)
+ if ((fGrfWH != 0.F) && (fGrfWH < fWinWH))
+ {
+ aSize.Width() = (long)(aPageSize.Height() * fGrfWH);
+ aSize.Height()= aPageSize.Height();
+ }
+ else
+ {
+ aSize.Width() = aPageSize.Width();
+ aSize.Height()= (long)(aPageSize.Width() / fGrfWH);
+ }
+ }
+
+
+ // Ausgaberechteck fuer Grafik setzen
+ Point aPnt ((aPageSize.Width() - aSize.Width()) / 2,
+ (aPageSize.Height() - aSize.Height()) / 2);
+ aPnt += Point(pPage->GetLftBorder(), pPage->GetUppBorder());
+ Rectangle aRect (aPnt, aSize);
+
+ SdrGrafObj* pGrafObj = NULL;
+
+ sal_Bool bInsertNewObject = sal_True;
+
+ if ( mpDrawView->AreObjectsMarked() )
+ {
+ /******************************************************
+ * Ist ein leeres Graphik-Objekt vorhanden?
+ ******************************************************/
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ if (pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF)
+ {
+ pGrafObj = (SdrGrafObj*) pObj;
+
+ if( pGrafObj->IsEmptyPresObj() )
+ {
+ /******************************************
+ * Das leere Graphik-Objekt bekommt eine neue
+ * Graphik
+ ******************************************/
+ bInsertNewObject = sal_False;
+
+ SdrGrafObj* pNewGrafObj = (SdrGrafObj*) pGrafObj->Clone();
+ pNewGrafObj->SetEmptyPresObj(sal_False);
+ pNewGrafObj->SetOutlinerParaObject(NULL);
+ pNewGrafObj->SetGraphic(aGraphic);
+
+ String aStr(mpDrawView->GetDescriptionOfMarkedObjects());
+ aStr += sal_Unicode(' ');
+ aStr += String(SdResId(STR_UNDO_REPLACE));
+ mpDrawView->BegUndo(aStr);
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+ mpDrawView->ReplaceObjectAtView(pGrafObj, *pPV, pNewGrafObj);
+ mpDrawView->EndUndo();
+ }
+ }
+ }
+ }
+
+
+ if( bInsertNewObject )
+ {
+ pGrafObj = new SdrGrafObj(aGraphic, aRect);
+ SdrPageView* pPV = mpDrawView->GetSdrPageView();
+ mpDrawView->InsertObjectAtView(pGrafObj, *pPV, SDRINSERT_SETDEFLAYER);
+ }
+
+ // Soll nur ein Link benutzt werden?
+ if( pGrafObj && pGal->IsLinkage() )
+ pGrafObj->SetGraphicLink( pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ), pGal->GetFilterName() );
+ }
+ // insert sound
+ else if( nFormats & SGA_FORMAT_SOUND )
+ {
+ const SfxStringItem aMediaURLItem( SID_INSERT_AVMEDIA, pGal->GetURL().GetMainURL( INetURLObject::NO_DECODE ) );
+ GetViewFrame()->GetDispatcher()->Execute( SID_INSERT_AVMEDIA, SFX_CALLMODE_SYNCHRON, &aMediaURLItem, 0L );
+ }
+
+ GetDocSh()->SetWaitCursor( sal_False );
+ }
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Statuswerte fuer Gallery zurueckgeben
+|*
+\************************************************************************/
+
+void DrawViewShell::GetGalleryState(SfxItemSet& )
+{
+}
+
+/*************************************************************************
+|*
+|* Makros fuer die Attributeinstellungen bearbeiten
+|*
+\************************************************************************/
+
+//
+// die vorgehensweise fuer die attributaenderung ist praktisch ueberall identisch
+// 1. bisherige attribute auslesen
+// 2. parameter aus dem basic-set auslesen
+// 3. gewaehltes item aus dem attribut-set loeschen
+// 4. neues attribut-item erzeugen
+// 5. item in den set eintragen
+//
+void DrawViewShell::AttrExec (SfxRequest &rReq)
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if(HasCurrentFunction(SID_PRESENTATION))
+ return;
+
+ CheckLineTo (rReq);
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ SfxItemSet* pAttr = new SfxItemSet ( GetDoc()->GetPool() );
+
+ GetView()->GetAttributes( *pAttr );
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ switch (rReq.GetSlot ())
+ {
+ // neuen fuellstil setzen
+ case SID_SETFILLSTYLE :
+ if (pArgs)
+ if (pArgs->Count () == 1)
+ {
+ SFX_REQUEST_ARG (rReq, pFillStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
+ if (CHECK_RANGE (XFILL_NONE, (sal_Int32)pFillStyle->GetValue (), XFILL_BITMAP))
+ {
+ pAttr->ClearItem (XATTR_FILLSTYLE);
+ pAttr->Put (XFillStyleItem ((XFillStyle) pFillStyle->GetValue ()), XATTR_FILLSTYLE);
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ }
+ else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ // linienstil neu bestimmen
+ case SID_SETLINESTYLE :
+ if (pArgs)
+ if (pArgs->Count () == 1)
+ {
+ SFX_REQUEST_ARG (rReq, pLineStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
+ if (CHECK_RANGE (XLINE_NONE, (sal_Int32)pLineStyle->GetValue (), XLINE_DASH))
+ {
+ pAttr->ClearItem (XATTR_LINESTYLE);
+ pAttr->Put (XLineStyleItem ((XLineStyle) pLineStyle->GetValue ()), XATTR_LINESTYLE);
+ rBindings.Invalidate (SID_ATTR_LINE_STYLE);
+ }
+ else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ // linienbreite setzen
+ case SID_SETLINEWIDTH :
+ if (pArgs)
+ if (pArgs->Count () == 1)
+ {
+ SFX_REQUEST_ARG (rReq, pLineWidth, SfxUInt32Item, ID_VAL_WIDTH, sal_False);
+ pAttr->ClearItem (XATTR_LINEWIDTH);
+ pAttr->Put (XLineWidthItem (pLineWidth->GetValue ()), XATTR_LINEWIDTH);
+ rBindings.Invalidate (SID_ATTR_LINE_WIDTH);
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ case SID_SETFILLCOLOR :
+ if (pArgs)
+ if (pArgs->Count () == 3)
+ {
+ SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False);
+ SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False);
+ SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False);
+
+ pAttr->ClearItem (XATTR_FILLCOLOR);
+ pAttr->ClearItem (XATTR_FILLSTYLE);
+ pAttr->Put (XFillColorItem (-1, Color ((sal_uInt8) pRed->GetValue (),
+ (sal_uInt8) pGreen->GetValue (),
+ (sal_uInt8) pBlue->GetValue ())),
+ XATTR_FILLCOLOR);
+ pAttr->Put (XFillStyleItem (XFILL_SOLID), XATTR_FILLSTYLE);
+ rBindings.Invalidate (SID_ATTR_FILL_COLOR);
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ case SID_SETLINECOLOR :
+ if (pArgs)
+ if (pArgs->Count () == 3)
+ {
+ SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False);
+ SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False);
+ SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False);
+
+ pAttr->ClearItem (XATTR_LINECOLOR);
+ pAttr->Put (XLineColorItem (-1, Color ((sal_uInt8) pRed->GetValue (),
+ (sal_uInt8) pGreen->GetValue (),
+ (sal_uInt8) pBlue->GetValue ())),
+ XATTR_LINECOLOR);
+ rBindings.Invalidate (SID_ATTR_LINE_COLOR);
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ case SID_SETGRADSTARTCOLOR :
+ case SID_SETGRADENDCOLOR :
+ if (pArgs)
+ if (pArgs->Count () == 4)
+ {
+ SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
+ SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False);
+ SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False);
+ SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False);
+
+ XGradientList *pGradientList = GetDoc()->GetGradientList ();
+ long nCounts = pGradientList->Count ();
+ Color aColor ((sal_uInt8) pRed->GetValue (),
+ (sal_uInt8) pGreen->GetValue (),
+ (sal_uInt8) pBlue->GetValue ());
+ long i;
+
+ pAttr->ClearItem (XATTR_FILLGRADIENT);
+ pAttr->ClearItem (XATTR_FILLSTYLE);
+
+ for ( i = 0; i < nCounts; i ++)
+ {
+ XGradientEntry *pEntry = pGradientList->GetGradient (i);
+
+ if (pEntry->GetName () == pName->GetValue ())
+ {
+ XGradient &rGradient = pEntry->GetGradient ();
+
+ if (rReq.GetSlot () == SID_SETGRADSTARTCOLOR) rGradient.SetStartColor (aColor);
+ else rGradient.SetEndColor (aColor);
+
+ pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
+ pAttr->Put (XFillGradientItem (pName->GetValue (), rGradient), XATTR_FILLGRADIENT);
+ break;
+ }
+ }
+
+ if (i >= nCounts)
+ {
+ Color aBlack (0, 0, 0);
+ XGradient aGradient ((rReq.GetSlot () == SID_SETGRADSTARTCOLOR)
+ ? aColor
+ : aBlack,
+ (rReq.GetSlot () == SID_SETGRADENDCOLOR)
+ ? aColor
+ : aBlack);
+
+ GetDoc()->GetGradientList ()->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
+
+ pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
+ pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
+ }
+
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ case SID_SETHATCHCOLOR :
+ if (pArgs)
+ if (pArgs->Count () == 4)
+ {
+ SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
+ SFX_REQUEST_ARG (rReq, pRed, SfxUInt32Item, ID_VAL_RED, sal_False);
+ SFX_REQUEST_ARG (rReq, pGreen, SfxUInt32Item, ID_VAL_GREEN, sal_False);
+ SFX_REQUEST_ARG (rReq, pBlue, SfxUInt32Item, ID_VAL_BLUE, sal_False);
+
+ XHatchList *pHatchList = GetDoc()->GetHatchList ();
+ long nCounts = pHatchList->Count ();
+ Color aColor ((sal_uInt8) pRed->GetValue (),
+ (sal_uInt8) pGreen->GetValue (),
+ (sal_uInt8) pBlue->GetValue ());
+ long i;
+
+ pAttr->ClearItem (XATTR_FILLHATCH);
+ pAttr->ClearItem (XATTR_FILLSTYLE);
+
+ for ( i = 0; i < nCounts; i ++)
+ {
+ XHatchEntry *pEntry = pHatchList->GetHatch (i);
+
+ if (pEntry->GetName () == pName->GetValue ())
+ {
+ XHatch &rHatch = pEntry->GetHatch ();
+
+ rHatch.SetColor (aColor);
+
+ pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
+ pAttr->Put (XFillHatchItem (pName->GetValue (), rHatch), XATTR_FILLHATCH);
+ break;
+ }
+ }
+
+ if (i >= nCounts)
+ {
+ XHatch aHatch (aColor);
+
+ GetDoc()->GetHatchList ()->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
+
+ pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
+ pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
+ }
+
+ rBindings.Invalidate (SID_ATTR_FILL_HATCH);
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ // einstellungen fuer liniendash
+ case SID_DASH :
+ if (pArgs)
+ if (pArgs->Count () == 7)
+ {
+ SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
+ SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
+ SFX_REQUEST_ARG (rReq, pDots, SfxUInt32Item, ID_VAL_DOTS, sal_False);
+ SFX_REQUEST_ARG (rReq, pDotLen, SfxUInt32Item, ID_VAL_DOTLEN, sal_False);
+ SFX_REQUEST_ARG (rReq, pDashes, SfxUInt32Item, ID_VAL_DASHES, sal_False);
+ SFX_REQUEST_ARG (rReq, pDashLen, SfxUInt32Item, ID_VAL_DASHLEN, sal_False);
+ SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, sal_False);
+
+ if (CHECK_RANGE (XDASH_RECT, (sal_Int32)pStyle->GetValue (), XDASH_ROUNDRELATIVE))
+ {
+ XDash aNewDash ((XDashStyle) pStyle->GetValue (), (short) pDots->GetValue (), pDotLen->GetValue (),
+ (short) pDashes->GetValue (), pDashLen->GetValue (), pDistance->GetValue ());
+
+ pAttr->ClearItem (XATTR_LINEDASH);
+ pAttr->ClearItem (XATTR_LINESTYLE);
+
+ XDashList *pDashList = GetDoc()->GetDashList ();
+ long nCounts = pDashList->Count ();
+ XDashEntry *pEntry = new XDashEntry (aNewDash, pName->GetValue ());
+ long i;
+
+ for ( i = 0; i < nCounts; i++ )
+ if (pDashList->GetDash (i)->GetName () == pName->GetValue ())
+ break;
+
+ if (i < nCounts)
+ pDashList->Replace (pEntry, i);
+ else
+ pDashList->Insert (pEntry);
+
+ pAttr->Put (XLineDashItem (pName->GetValue (), aNewDash), XATTR_LINEDASH);
+ pAttr->Put (XLineStyleItem (XLINE_DASH), XATTR_LINESTYLE);
+ rBindings.Invalidate (SID_ATTR_LINE_DASH);
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ }
+ else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ // einstellungen fuer farbverlauf
+ case SID_GRADIENT :
+ if (pArgs)
+ if (pArgs->Count () == 8)
+ {
+ SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
+ SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
+ SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, sal_False);
+ SFX_REQUEST_ARG (rReq, pBorder, SfxUInt32Item, ID_VAL_BORDER, sal_False);
+ SFX_REQUEST_ARG (rReq, pCenterX, SfxUInt32Item, ID_VAL_CENTER_X, sal_False);
+ SFX_REQUEST_ARG (rReq, pCenterY, SfxUInt32Item, ID_VAL_CENTER_Y, sal_False);
+ SFX_REQUEST_ARG (rReq, pStart, SfxUInt32Item, ID_VAL_STARTINTENS, sal_False);
+ SFX_REQUEST_ARG (rReq, pEnd, SfxUInt32Item, ID_VAL_ENDINTENS, sal_False);
+
+ if (CHECK_RANGE (XGRAD_LINEAR, (sal_Int32)pStyle->GetValue (), XGRAD_RECT) &&
+ CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360) &&
+ CHECK_RANGE (0, (sal_Int32)pBorder->GetValue (), 100) &&
+ CHECK_RANGE (0, (sal_Int32)pCenterX->GetValue (), 100) &&
+ CHECK_RANGE (0, (sal_Int32)pCenterY->GetValue (), 100) &&
+ CHECK_RANGE (0, (sal_Int32)pStart->GetValue (), 100) &&
+ CHECK_RANGE (0, (sal_Int32)pEnd->GetValue (), 100))
+ {
+ pAttr->ClearItem (XATTR_FILLGRADIENT);
+ pAttr->ClearItem (XATTR_FILLSTYLE);
+
+ XGradientList *pGradientList = GetDoc()->GetGradientList ();
+ long nCounts = pGradientList->Count ();
+ long i;
+
+ for ( i = 0; i < nCounts; i++ )
+ {
+ XGradientEntry *pEntry = pGradientList->GetGradient (i);
+
+ if (pEntry->GetName () == pName->GetValue ())
+ {
+ XGradient &rGradient = pEntry->GetGradient ();
+
+ rGradient.SetGradientStyle ((XGradientStyle) pStyle->GetValue ());
+ rGradient.SetAngle (pAngle->GetValue () * 10);
+ rGradient.SetBorder ((short) pBorder->GetValue ());
+ rGradient.SetXOffset ((short) pCenterX->GetValue ());
+ rGradient.SetYOffset ((short) pCenterY->GetValue ());
+ rGradient.SetStartIntens ((short) pStart->GetValue ());
+ rGradient.SetEndIntens ((short) pEnd->GetValue ());
+
+ pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
+ pAttr->Put (XFillGradientItem (pName->GetValue (), rGradient), XATTR_FILLGRADIENT);
+ break;
+ }
+ }
+
+ if (i >= nCounts)
+ {
+ Color aBlack (0, 0, 0);
+ XGradient aGradient (aBlack, aBlack, (XGradientStyle) pStyle->GetValue (),
+ pAngle->GetValue () * 10, (short) pCenterX->GetValue (),
+ (short) pCenterY->GetValue (), (short) pBorder->GetValue (),
+ (short) pStart->GetValue (), (short) pEnd->GetValue ());
+
+ pGradientList->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
+ pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
+ pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
+ }
+
+ rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ }
+ else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ // einstellungen fuer schraffur
+ case SID_HATCH :
+ if (pArgs)
+ if (pArgs->Count () == 4)
+ {
+ SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
+ SFX_REQUEST_ARG (rReq, pStyle, SfxUInt32Item, ID_VAL_STYLE, sal_False);
+ SFX_REQUEST_ARG (rReq, pDistance, SfxUInt32Item, ID_VAL_DISTANCE, sal_False);
+ SFX_REQUEST_ARG (rReq, pAngle, SfxUInt32Item, ID_VAL_ANGLE, sal_False);
+
+ if (CHECK_RANGE (XHATCH_SINGLE, (sal_Int32)pStyle->GetValue (), XHATCH_TRIPLE) &&
+ CHECK_RANGE (0, (sal_Int32)pAngle->GetValue (), 360))
+ {
+ pAttr->ClearItem (XATTR_FILLHATCH);
+ pAttr->ClearItem (XATTR_FILLSTYLE);
+
+ XHatchList *pHatchList = GetDoc()->GetHatchList ();
+ long nCounts = pHatchList->Count ();
+ long i;
+
+ for ( i = 0; i < nCounts; i++ )
+ {
+ XHatchEntry *pEntry = pHatchList->GetHatch (i);
+
+ if (pEntry->GetName () == pName->GetValue ())
+ {
+ XHatch &rHatch = pEntry->GetHatch ();
+
+ rHatch.SetHatchStyle ((XHatchStyle) pStyle->GetValue ());
+ rHatch.SetDistance (pDistance->GetValue ());
+ rHatch.SetAngle (pAngle->GetValue () * 10);
+
+ pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
+ pAttr->Put (XFillHatchItem (pName->GetValue (), rHatch), XATTR_FILLHATCH);
+ break;
+ }
+ }
+
+ if (i >= nCounts)
+ {
+ Color aBlack (0, 0, 0);
+ XHatch aHatch (aBlack, (XHatchStyle) pStyle->GetValue (), pDistance->GetValue (),
+ pAngle->GetValue () * 10);
+
+ pHatchList->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
+ pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
+ pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
+ }
+
+ rBindings.Invalidate (SID_ATTR_FILL_HATCH);
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ }
+ else StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ case SID_SELECTGRADIENT :
+ if (pArgs)
+ if (pArgs->Count () == 1)
+ {
+ SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
+
+ XGradientList *pGradientList = GetDoc()->GetGradientList ();
+ long nCounts = pGradientList->Count ();
+
+ for (long i = 0;
+ i < nCounts;
+ i ++)
+ {
+ XGradientEntry *pEntry = pGradientList->GetGradient (i);
+
+ if (pEntry->GetName () == pName->GetValue ())
+ {
+ pAttr->ClearItem (XATTR_FILLGRADIENT);
+ pAttr->ClearItem (XATTR_FILLSTYLE);
+ pAttr->Put (XFillStyleItem (XFILL_GRADIENT), XATTR_FILLSTYLE);
+ pAttr->Put (XFillGradientItem (pName->GetValue (), pEntry->GetGradient ()), XATTR_FILLGRADIENT);
+
+ rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ break;
+ }
+ }
+
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ case SID_SELECTHATCH :
+ if (pArgs)
+ if (pArgs->Count () == 1)
+ {
+ SFX_REQUEST_ARG (rReq, pName, SfxStringItem, ID_VAL_INDEX, sal_False);
+
+ XHatchList *pHatchList = GetDoc()->GetHatchList ();
+ long nCounts = pHatchList->Count ();
+
+ for (long i = 0;
+ i < nCounts;
+ i ++)
+ {
+ XHatchEntry *pEntry = pHatchList->GetHatch (i);
+
+ if (pEntry->GetName () == pName->GetValue ())
+ {
+ pAttr->ClearItem (XATTR_FILLHATCH);
+ pAttr->ClearItem (XATTR_FILLSTYLE);
+ pAttr->Put (XFillStyleItem (XFILL_HATCH), XATTR_FILLSTYLE);
+ pAttr->Put (XFillHatchItem (pName->GetValue (), pEntry->GetHatch ()), XATTR_FILLHATCH);
+
+ rBindings.Invalidate (SID_ATTR_FILL_HATCH);
+ rBindings.Invalidate (SID_ATTR_FILL_STYLE);
+ break;
+ }
+ }
+
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+ case SID_UNSELECT :
+ mpDrawView->UnmarkAll ();
+ break;
+
+ case SID_GETRED :
+ if (pArgs)
+ if (pArgs->Count () == 1)
+ {
+ break;
+ }
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ break;
+
+/* case SID_SETFONTFAMILYNAME :
+ case SID_SETFONTSTYLENAME :
+ case SID_SETFONTFAMILY :
+ case SID_SETFONTPITCH :
+ case SID_SETFONTCHARSET :
+ case SID_SETFONTPOSTURE :
+ case SID_SETFONTWEIGHT :
+ case SID_SETFONTUNDERLINE :
+ case SID_SETFONTCROSSEDOUT :
+ case SID_SETFONTSHADOWED :
+ case SID_SETFONTCONTOUR :
+ case SID_SETFONTCOLOR :
+ case SID_SETFONTLANGUAGE :
+ case SID_SETFONTWORDLINE :
+ case SID_SETFONTCASEMAP :
+ case SID_SETFONTESCAPE :
+ case SID_SETFONTKERNING :
+ break;*/
+
+ default :
+ ;
+ }
+
+ mpDrawView->SetAttributes (*(const SfxItemSet *) pAttr);
+ rReq.Ignore ();
+ delete pAttr;
+}
+
+/*************************************************************************
+|*
+|* Makros fuer die Attributeinstellungen bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::AttrState (SfxItemSet& rSet)
+{
+ SfxWhichIter aIter (rSet);
+ sal_uInt16 nWhich = aIter.FirstWhich ();
+ SfxItemSet aAttr( GetDoc()->GetPool() );
+ mpDrawView->GetAttributes( aAttr );
+
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_GETFILLSTYLE :
+ {
+ const XFillStyleItem &rFillStyleItem = (const XFillStyleItem &) aAttr.Get (XATTR_FILLSTYLE);
+
+ rSet.Put (SfxUInt32Item (nWhich, (long) rFillStyleItem.GetValue ()));
+ break;
+ }
+
+ case SID_GETLINESTYLE :
+ {
+ const XLineStyleItem &rLineStyleItem = (const XLineStyleItem &) aAttr.Get (XATTR_LINESTYLE);
+
+ rSet.Put (SfxUInt32Item (nWhich, (long) rLineStyleItem.GetValue ()));
+ break;
+ }
+
+ case SID_GETLINEWIDTH :
+ {
+ const XLineWidthItem &rLineWidthItem = (const XLineWidthItem &) aAttr.Get (XATTR_LINEWIDTH);
+
+ rSet.Put (SfxUInt32Item (nWhich, (long) rLineWidthItem.GetValue ()));
+ break;
+ }
+
+ case SID_GETGREEN :
+ case SID_GETRED :
+ case SID_GETBLUE :
+ {
+ const SfxUInt32Item &rWhatKind = (const SfxUInt32Item &) rSet.Get (ID_VAL_WHATKIND);
+ Color aColor;
+
+ switch (rWhatKind.GetValue ())
+ {
+ case 1 :
+ {
+ const XLineColorItem &rLineColorItem = (const XLineColorItem &) aAttr.Get (XATTR_LINECOLOR);
+
+ aColor = rLineColorItem.GetColorValue ();
+ break;
+ }
+
+ case 2 :
+ {
+ const XFillColorItem &rFillColorItem = (const XFillColorItem &) aAttr.Get (XATTR_FILLCOLOR);
+
+ aColor = rFillColorItem.GetColorValue ();
+ break;
+ }
+
+ case 3 :
+ case 4 :
+ {
+ const XFillGradientItem &rFillGradientItem = (const XFillGradientItem &) aAttr.Get (XATTR_FILLGRADIENT);
+ const XGradient &rGradient = rFillGradientItem.GetGradientValue ();
+
+ aColor = (rWhatKind.GetValue () == 3)
+ ? rGradient.GetStartColor ()
+ : rGradient.GetEndColor ();
+ break;
+ }
+
+ case 5:
+ {
+ const XFillHatchItem &rFillHatchItem = (const XFillHatchItem &) aAttr.Get (XATTR_FILLHATCH);
+ const XHatch &rHatch = rFillHatchItem.GetHatchValue ();
+
+ aColor = rHatch.GetColor ();
+ break;
+ }
+
+ default :
+ ;
+ }
+
+ rSet.Put (SfxUInt32Item (nWhich, (long) ((nWhich == SID_GETRED)
+ ? aColor.GetRed ()
+ : (nWhich == SID_GETGREEN)
+ ? aColor.GetGreen ()
+ : aColor.GetBlue ())));
+ break;
+ }
+
+ default :
+ ;
+ }
+
+ nWhich = aIter.NextWhich ();
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx
new file mode 100755
index 000000000000..dfef973faeb8
--- /dev/null
+++ b/sd/source/ui/view/drviewsa.cxx
@@ -0,0 +1,860 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/processfactory.hxx>
+#ifndef _SVX_SIZEITEM
+#include <editeng/sizeitem.hxx>
+#endif
+#include <svx/svdlayer.hxx>
+#ifndef _SVX_ZOOMITEM
+#include <svx/zoomitem.hxx>
+#endif
+#include <svx/svdpagv.hxx>
+#include <svl/ptitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdopath.hxx>
+#include <sfx2/docfile.hxx>
+#include <svx/zoomslideritem.hxx>
+#include <svl/eitem.hxx>
+
+#ifndef _SVX_DIALOGS_HRC
+#include <svx/dialogs.hrc>
+#endif
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <svx/clipfmtitem.hxx>
+
+
+#include <sfx2/viewfrm.hxx>
+#include <svx/fmshell.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svtools/cliplistener.hxx>
+#include <svx/float3d.hxx>
+#include "helpids.h"
+
+#include "view/viewoverlaymanager.hxx"
+#include "app.hrc"
+#include "helpids.h"
+#include "strings.hrc"
+#include "res_bmp.hrc"
+#include "sdpage.hxx"
+#include "FrameView.hxx"
+#include "drawdoc.hxx"
+#include "sdresid.hxx"
+#include "DrawDocShell.hxx"
+#include "Window.hxx"
+#include "fupoor.hxx"
+#include "fusel.hxx"
+#include "drawview.hxx"
+#include "SdUnoDrawView.hxx"
+#include "ViewShellBase.hxx"
+#include "SdUnoDrawView.hxx"
+#include "slideshow.hxx"
+#include "ToolBarManager.hxx"
+#include "annotationmanager.hxx"
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+namespace {
+static const ::rtl::OUString MASTER_VIEW_TOOL_BAR_NAME(
+ ::rtl::OUString::createFromAscii("masterviewtoolbar"));
+}
+
+namespace sd {
+
+sal_Bool DrawViewShell::mbPipette = sal_False;
+
+// ------------------------
+// - ScannerEventListener -
+// ------------------------
+
+class ScannerEventListener : public ::cppu::WeakImplHelper1< ::com::sun::star::lang::XEventListener >
+{
+private:
+
+ DrawViewShell* mpParent;
+
+public:
+
+ ScannerEventListener( DrawViewShell* pParent ) : mpParent( pParent ) {};
+ ~ScannerEventListener();
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& rEventObject ) throw (::com::sun::star::uno::RuntimeException);
+
+ void ParentDestroyed() { mpParent = NULL; }
+};
+
+// -----------------------------------------------------------------------------
+
+ScannerEventListener::~ScannerEventListener()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ScannerEventListener::disposing( const ::com::sun::star::lang::EventObject& rEventObject ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if( mpParent )
+ mpParent->ScannerEvent( rEventObject );
+}
+
+/*************************************************************************
+|*
+|* Standard-Konstruktor
+|*
+\************************************************************************/
+
+DrawViewShell::DrawViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, ::Window* pParentWindow, PageKind ePageKind, FrameView* pFrameViewArgument )
+: ViewShell (pFrame, pParentWindow, rViewShellBase)
+, maTabControl(this, pParentWindow)
+, mbIsInSwitchPage(false)
+{
+ if (pFrameViewArgument != NULL)
+ mpFrameView = pFrameViewArgument;
+ else
+ mpFrameView = new FrameView(GetDoc());
+ Construct(GetDocSh(), ePageKind);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+DrawViewShell::~DrawViewShell()
+{
+ mpAnnotationManager.reset();
+ mpViewOverlayManager.reset();
+
+ OSL_ASSERT (GetViewShell()!=NULL);
+
+ if( mxScannerListener.is() )
+ static_cast< ScannerEventListener* >( mxScannerListener.get() )->ParentDestroyed();
+
+ // #96642# Remove references to items within Svx3DWin
+ // (maybe do a listening sometime in Svx3DWin)
+ sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
+ SfxChildWindow* pWindow = GetViewFrame() ? GetViewFrame()->GetChildWindow(nId) : NULL;
+ if(pWindow)
+ {
+ Svx3DWin* p3DWin = static_cast< Svx3DWin* > (pWindow->GetWindow());
+ if(p3DWin)
+ p3DWin->DocumentReload();
+ }
+
+ EndListening (*GetDoc());
+ EndListening (*GetDocSh());
+
+ if( SlideShow::IsRunning(*this) )
+ StopSlideShow(false);
+
+ DisposeFunctions();
+
+ SdPage* pPage;
+ sal_uInt16 aPageCnt = GetDoc()->GetSdPageCount(mePageKind);
+
+ for (sal_uInt16 i = 0; i < aPageCnt; i++)
+ {
+ pPage = GetDoc()->GetSdPage(i, mePageKind);
+
+ if (pPage == mpActualPage)
+ {
+ GetDoc()->SetSelected(pPage, sal_True);
+ }
+ else
+ {
+ GetDoc()->SetSelected(pPage, sal_False);
+ }
+ }
+
+ if ( mpClipEvtLstnr )
+ {
+ mpClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_False );
+ mpClipEvtLstnr->ClearCallbackLink(); // #103849# prevent callback if another thread is waiting
+ mpClipEvtLstnr->release();
+ }
+
+ delete mpDrawView;
+ // Set mpView to NULL so that the destructor of the ViewShell base class
+ // does not access it.
+ mpView = mpDrawView = NULL;
+
+ mpFrameView->Disconnect();
+ delete [] mpSlotArray;
+}
+
+/*************************************************************************
+|*
+|* gemeinsamer Initialisierungsanteil der beiden Konstruktoren
+|*
+\************************************************************************/
+
+void DrawViewShell::Construct(DrawDocShell* pDocSh, PageKind eInitialPageKind)
+{
+ mpActualPage = 0;
+ mbMousePosFreezed = sal_False;
+ mbReadOnly = GetDocSh()->IsReadOnly();
+ mpSlotArray = 0;
+ mpClipEvtLstnr = 0;
+ mbPastePossible = sal_False;
+ mbIsLayerModeActive = false;
+
+ mpFrameView->Connect();
+
+ OSL_ASSERT (GetViewShell()!=NULL);
+
+ // Array fuer Slot-/ImageMapping:
+ // Gerader Eintrag: Haupt-/ToolboxSlot
+ // Ungerader Eintrag: gemappter Slot
+ // Achtung: Anpassen von GetIdBySubId() !!!
+ // Reihenfolge (insbesondere Zoom) darf nicht geaendert werden !!!
+ mpSlotArray = new sal_uInt16[ SLOTARRAY_COUNT ];
+ mpSlotArray[ 0 ] = SID_OBJECT_CHOOSE_MODE;
+ mpSlotArray[ 1 ] = SID_OBJECT_ROTATE;
+ mpSlotArray[ 2 ] = SID_OBJECT_ALIGN;
+ mpSlotArray[ 3 ] = SID_OBJECT_ALIGN_LEFT;
+ mpSlotArray[ 4 ] = SID_ZOOM_TOOLBOX;
+ mpSlotArray[ 5 ] = SID_ZOOM_TOOLBOX;
+ mpSlotArray[ 6 ] = SID_DRAWTBX_TEXT;
+ mpSlotArray[ 7 ] = SID_ATTR_CHAR;
+ mpSlotArray[ 8 ] = SID_DRAWTBX_RECTANGLES;
+ mpSlotArray[ 9 ] = SID_DRAW_RECT;
+ mpSlotArray[ 10 ] = SID_DRAWTBX_ELLIPSES;
+ mpSlotArray[ 11 ] = SID_DRAW_ELLIPSE;
+ mpSlotArray[ 12 ] = SID_DRAWTBX_LINES;
+ mpSlotArray[ 13 ] = SID_DRAW_FREELINE_NOFILL;
+ mpSlotArray[ 14 ] = SID_DRAWTBX_3D_OBJECTS;
+ mpSlotArray[ 15 ] = SID_3D_CUBE;
+ mpSlotArray[ 16 ] = SID_DRAWTBX_INSERT;
+ mpSlotArray[ 17 ] = SID_INSERT_DIAGRAM;
+ mpSlotArray[ 18 ] = SID_POSITION;
+ mpSlotArray[ 19 ] = SID_FRAME_TO_TOP;
+ mpSlotArray[ 20 ] = SID_DRAWTBX_CONNECTORS;
+ mpSlotArray[ 21 ] = SID_TOOL_CONNECTOR;
+ mpSlotArray[ 22 ] = SID_DRAWTBX_ARROWS;
+ mpSlotArray[ 23 ] = SID_LINE_ARROW_END;
+
+ SetPool( &GetDoc()->GetPool() );
+
+ GetDoc()->CreateFirstPages();
+
+ mpDrawView = new DrawView(pDocSh, GetActiveWindow(), this);
+ mpView = mpDrawView; // Pointer der Basisklasse ViewShell
+ mpDrawView->SetSwapAsynchron(sal_True); // Asynchrones Laden von Graphiken
+
+ // We do not read the page kind from the frame view anymore so we have
+ // to set it in order to resync frame view and this view.
+ mpFrameView->SetPageKind(eInitialPageKind);
+ mePageKind = eInitialPageKind;
+ meEditMode = EM_PAGE;
+ DocumentType eDocType = GetDoc()->GetDocumentType(); // RTTI fasst hier noch nicht
+ switch (mePageKind)
+ {
+ case PK_STANDARD:
+ meShellType = ST_IMPRESS;
+ break;
+
+ case PK_NOTES:
+ meShellType = ST_NOTES;
+ break;
+
+ case PK_HANDOUT:
+ meShellType = ST_HANDOUT;
+ break;
+ }
+
+ Size aPageSize( GetDoc()->GetSdPage(0, mePageKind)->GetSize() );
+ Point aPageOrg( aPageSize.Width(), aPageSize.Height() / 2);
+ Size aSize(aPageSize.Width() * 3, aPageSize.Height() * 2);
+ InitWindows(aPageOrg, aSize, Point(-1, -1));
+
+ Point aVisAreaPos;
+
+ if ( pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ {
+ aVisAreaPos = pDocSh->GetVisArea(ASPECT_CONTENT).TopLeft();
+ }
+
+ mpDrawView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
+
+ // Objekte koennen max. so gross wie die ViewSize werden
+ GetDoc()->SetMaxObjSize(aSize);
+
+ // Split-Handler fuer TabControls
+ maTabControl.SetSplitHdl( LINK( this, DrawViewShell, TabSplitHdl ) );
+
+ // Damit der richtige EditMode von der FrameView komplett eingestellt
+ // werden kann, wird hier ein aktuell anderer gewaehlt (kleiner Trick)
+ if (mpFrameView->GetViewShEditMode(mePageKind) == EM_PAGE)
+ {
+ meEditMode = EM_MASTERPAGE;
+ }
+ else
+ {
+ meEditMode = EM_PAGE;
+ }
+
+ // Einstellungen der FrameView uebernehmen
+ ReadFrameViewData(mpFrameView);
+
+ if( eDocType == DOCUMENT_TYPE_DRAW )
+ {
+ SetHelpId( SD_IF_SDGRAPHICVIEWSHELL );
+ GetActiveWindow()->SetHelpId( HID_SDGRAPHICVIEWSHELL );
+ GetActiveWindow()->SetUniqueId( HID_SDGRAPHICVIEWSHELL );
+ }
+ else
+ {
+ if (mePageKind == PK_NOTES)
+ {
+ SetHelpId( SID_NOTESMODE );
+ GetActiveWindow()->SetHelpId( CMD_SID_NOTESMODE );
+ GetActiveWindow()->SetUniqueId( CMD_SID_NOTESMODE );
+
+ // AutoLayouts muessen erzeugt sein
+ GetDoc()->StopWorkStartupDelay();
+ }
+ else if (mePageKind == PK_HANDOUT)
+ {
+ SetHelpId( SID_HANDOUTMODE );
+ GetActiveWindow()->SetHelpId( CMD_SID_HANDOUTMODE );
+ GetActiveWindow()->SetUniqueId( CMD_SID_HANDOUTMODE );
+
+ // AutoLayouts muessen erzeugt sein
+ GetDoc()->StopWorkStartupDelay();
+ }
+ else
+ {
+ SetHelpId( SD_IF_SDDRAWVIEWSHELL );
+ GetActiveWindow()->SetHelpId( HID_SDDRAWVIEWSHELL );
+ GetActiveWindow()->SetUniqueId( HID_SDDRAWVIEWSHELL );
+ }
+ }
+
+ // Selektionsfunktion starten
+ SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
+ FuPermanent(aReq);
+ mpDrawView->SetFrameDragSingles(sal_True);
+
+ if (pDocSh->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED)
+ {
+ mbZoomOnPage = sal_False;
+ }
+ else
+ {
+ mbZoomOnPage = sal_True;
+ }
+
+ mbIsRulerDrag = sal_False;
+
+ String aName( RTL_CONSTASCII_USTRINGPARAM("DrawViewShell"));
+ SetName (aName);
+
+ mnLockCount = 0UL;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+
+ if( xMgr.is() )
+ {
+ mxScannerManager = ::com::sun::star::uno::Reference< ::com::sun::star::scanner::XScannerManager >(
+ xMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.scanner.ScannerManager" ) ),
+ ::com::sun::star::uno::UNO_QUERY );
+
+ if( mxScannerManager.is() )
+ {
+ mxScannerListener = ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >(
+ static_cast< ::cppu::OWeakObject* >( new ScannerEventListener( this ) ),
+ ::com::sun::star::uno::UNO_QUERY );
+ }
+ }
+
+ mpAnnotationManager.reset( new AnnotationManager( GetViewShellBase() ) );
+ mpViewOverlayManager.reset( new ViewOverlayManager( GetViewShellBase() ) );
+}
+
+
+
+
+void DrawViewShell::Init (bool bIsMainViewShell)
+{
+ ViewShell::Init(bIsMainViewShell);
+
+ StartListening (*GetDocSh());
+}
+
+
+
+
+void DrawViewShell::Shutdown (void)
+{
+ ViewShell::Shutdown();
+
+ if(SlideShow::IsRunning( GetViewShellBase() ) )
+ {
+ // Turn off effects.
+ GetDrawView()->SetAnimationMode(SDR_ANIMATION_DISABLE);
+ }
+}
+
+
+
+
+css::uno::Reference<css::drawing::XDrawSubController> DrawViewShell::CreateSubController (void)
+{
+ css::uno::Reference<css::drawing::XDrawSubController> xSubController;
+
+ if (IsMainViewShell())
+ {
+ // Create uno sub controller for the main view shell.
+ xSubController = css::uno::Reference<css::drawing::XDrawSubController>(
+ new SdUnoDrawView (
+ GetViewShellBase().GetDrawController(),
+ *this,
+ *GetView()));
+ }
+
+ return xSubController;
+}
+
+
+
+
+bool DrawViewShell::RelocateToParentWindow (::Window* pParentWindow)
+{
+ // DrawViewShells can not be relocated to a new parent window at the
+ // moment, so return <FALSE/> except when the given parent window is the
+ // parent window that is already in use.
+ return pParentWindow==GetParentWindow();
+}
+
+
+
+
+/*************************************************************************
+|*
+|* pruefe ob linienzuege gezeichnet werden muessen
+|*
+\************************************************************************/
+
+/*
+ linienzuege werden ueber makros als folge von
+ MoveTo (x, y)
+ LineTo (x, y) [oder BezierTo (x, y)]
+ LineTo (x, y)
+ :
+ dargestellt. einen endbefehl fuer die linienzuege
+ gibt es nicht, also muessen alle befehle in den
+ requests nach LineTo (BezierTo) abgetestet und die
+ punktparameter gesammelt werden.
+ der erste nicht-LineTo fuehrt dann dazu, dass aus
+ den gesammelten punkten der linienzug erzeugt wird
+*/
+
+void DrawViewShell::CheckLineTo(SfxRequest& rReq)
+{
+ (void)rReq;
+#ifdef DBG_UTIL
+ if(rReq.IsAPI())
+ {
+ if(SID_LINETO == rReq.GetSlot() || SID_BEZIERTO == rReq.GetSlot() || SID_MOVETO == rReq.GetSlot() )
+ {
+ DBG_ERROR("DrawViewShell::CheckLineTo: slots SID_LINETO, SID_BEZIERTO, SID_MOVETO no longer supported.");
+ }
+ }
+#endif
+
+ rReq.Ignore ();
+}
+
+/*************************************************************************
+|*
+|* veraendere die seitemparameter, wenn SID_PAGESIZE oder SID_PAGEMARGIN
+|*
+\************************************************************************/
+
+void DrawViewShell::SetupPage (Size &rSize,
+ long nLeft,
+ long nRight,
+ long nUpper,
+ long nLower,
+ sal_Bool bSize,
+ sal_Bool bMargin,
+ sal_Bool bScaleAll)
+{
+ sal_uInt16 nPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
+ sal_uInt16 i;
+
+ for (i = 0; i < nPageCnt; i++)
+ {
+ /**********************************************************************
+ * Erst alle MasterPages bearbeiten
+ **********************************************************************/
+ SdPage *pPage = GetDoc()->GetMasterSdPage(i, mePageKind);
+
+ if( pPage )
+ {
+ if( bSize )
+ {
+ Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
+ pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
+ pPage->SetSize(rSize);
+
+ }
+ if( bMargin )
+ {
+ pPage->SetLftBorder(nLeft);
+ pPage->SetRgtBorder(nRight);
+ pPage->SetUppBorder(nUpper);
+ pPage->SetLwrBorder(nLower);
+ }
+
+ if ( mePageKind == PK_STANDARD )
+ {
+ GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
+ }
+
+ pPage->CreateTitleAndLayout();
+ }
+ }
+
+ nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
+
+ for (i = 0; i < nPageCnt; i++)
+ {
+ /**********************************************************************
+ * Danach alle Pages bearbeiten
+ **********************************************************************/
+ SdPage *pPage = GetDoc()->GetSdPage(i, mePageKind);
+
+ if( pPage )
+ {
+ if( bSize )
+ {
+ Rectangle aBorderRect(nLeft, nUpper, nRight, nLower);
+ pPage->ScaleObjects(rSize, aBorderRect, bScaleAll);
+ pPage->SetSize(rSize);
+ }
+ if( bMargin )
+ {
+ pPage->SetLftBorder(nLeft);
+ pPage->SetRgtBorder(nRight);
+ pPage->SetUppBorder(nUpper);
+ pPage->SetLwrBorder(nLower);
+ }
+
+ if ( mePageKind == PK_STANDARD )
+ {
+ SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
+ pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
+ }
+
+ pPage->SetAutoLayout( pPage->GetAutoLayout() );
+ }
+ }
+
+ if ( mePageKind == PK_STANDARD )
+ {
+ SdPage* pHandoutPage = GetDoc()->GetSdPage(0, PK_HANDOUT);
+ pHandoutPage->CreateTitleAndLayout(sal_True);
+ }
+
+ long nWidth = mpActualPage->GetSize().Width();
+ long nHeight = mpActualPage->GetSize().Height();
+
+ Point aPageOrg(nWidth, nHeight / 2);
+ Size aSize( nWidth * 3, nHeight * 2);
+
+ InitWindows(aPageOrg, aSize, Point(-1, -1), sal_True);
+
+ Point aVisAreaPos;
+
+ if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ {
+ aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
+ }
+
+ GetView()->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aSize));
+
+ UpdateScrollBars();
+
+ Point aNewOrigin(mpActualPage->GetLftBorder(), mpActualPage->GetUppBorder());
+ GetView()->GetSdrPageView()->SetPageOrigin(aNewOrigin);
+
+ GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
+
+ // auf (neue) Seitengroesse zoomen
+ GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+}
+
+/*************************************************************************
+|*
+|* Statuswerte der Statusbar zurueckgeben
+|*
+\************************************************************************/
+
+void DrawViewShell::GetStatusBarState(SfxItemSet& rSet)
+{
+ // Zoom-Item
+ // Hier sollte der entsprechende Wert (Optimal ?, Seitenbreite oder
+ // Seite) mit Hilfe des ZoomItems weitergegeben werden !!!
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOM ) )
+ {
+ if (GetDocSh()->IsUIActive() || (SlideShow::IsRunning(GetViewShellBase())) )
+ {
+ rSet.DisableItem( SID_ATTR_ZOOM );
+ }
+ else
+ {
+ SvxZoomItem* pZoomItem;
+ sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom();
+
+ if( mbZoomOnPage )
+ pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom );
+ else
+ pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom );
+
+ // Bereich einschraenken
+ sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+
+ if( ( pPageView && pPageView->GetObjList()->GetObjCount() == 0 ) )
+ // || ( mpDrawView->GetMarkedObjectList().GetMarkCount() == 0 ) )
+ {
+ nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
+ }
+
+ pZoomItem->SetValueSet( nZoomValues );
+ rSet.Put( *pZoomItem );
+ delete pZoomItem;
+ }
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
+ {
+ rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
+ if (GetDocSh()->IsUIActive() || (xSlideshow.is() && xSlideshow->isRunning()) || !GetActiveWindow() )
+ {
+ rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
+ }
+ else
+ {
+ sd::Window * pActiveWindow = GetActiveWindow();
+ SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ;
+
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+ if( pPageView )
+ {
+ Point aPagePos(0, 0);
+ Size aPageSize = pPageView->GetPage()->GetSize();
+
+ aPagePos.X() += aPageSize.Width() / 2;
+ aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
+
+ aPagePos.Y() += aPageSize.Height() / 2;
+ aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
+ aPagePos.Y() -= aPageSize.Height() / 2;
+
+ aPagePos.X() -= aPageSize.Width() / 2;
+
+ Rectangle aFullPageZoomRect( aPagePos, aPageSize );
+ aZoomItem.AddSnappingPoint( pActiveWindow->GetZoomForRect( aFullPageZoomRect ) );
+ }
+ aZoomItem.AddSnappingPoint(100);
+ rSet.Put( aZoomItem );
+ }
+ }
+
+ Point aPos = GetActiveWindow()->PixelToLogic(maMousePos);
+ mpDrawView->GetSdrPageView()->LogicToPagePos(aPos);
+ Fraction aUIScale(GetDoc()->GetUIScale());
+ aPos.X() = Fraction(aPos.X()) / aUIScale;
+ aPos.Y() = Fraction(aPos.Y()) / aUIScale;
+
+ // Position- und Groesse-Items
+ if ( mpDrawView->IsAction() )
+ {
+ Rectangle aRect;
+ mpDrawView->TakeActionRect( aRect );
+
+ if ( aRect.IsEmpty() )
+ rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
+ else
+ {
+ mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
+ aPos = aRect.TopLeft();
+ aPos.X() = Fraction(aPos.X()) / aUIScale;
+ aPos.Y() = Fraction(aPos.Y()) / aUIScale;
+ rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos) );
+ Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
+ aSize.Height() = Fraction(aSize.Height()) / aUIScale;
+ aSize.Width() = Fraction(aSize.Width()) / aUIScale;
+ rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
+ }
+ }
+ else
+ {
+ if ( mpDrawView->AreObjectsMarked() )
+ {
+ Rectangle aRect = mpDrawView->GetAllMarkedRect();
+ mpDrawView->GetSdrPageView()->LogicToPagePos(aRect);
+
+ // Show the position of the selected shape(s)
+ Point aShapePosition (aRect.TopLeft());
+ aShapePosition.X() = Fraction(aShapePosition.X()) / aUIScale;
+ aShapePosition.Y() = Fraction(aShapePosition.Y()) / aUIScale;
+ rSet.Put (SfxPointItem(SID_ATTR_POSITION, aShapePosition));
+
+ Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() );
+ aSize.Height() = Fraction(aSize.Height()) / aUIScale;
+ aSize.Width() = Fraction(aSize.Width()) / aUIScale;
+ rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize) );
+ }
+ else
+ {
+ rSet.Put( SfxPointItem(SID_ATTR_POSITION, aPos) );
+ rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
+ }
+ }
+
+ // Display of current page and layer.
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) )
+ {
+ // Allways show the slide/page number.
+ String aString (SdResId( STR_SD_PAGE ));
+ aString += sal_Unicode(' ');
+ aString += UniString::CreateFromInt32( maTabControl.GetCurPageId() );
+ aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " ));
+ aString += UniString::CreateFromInt32( GetDoc()->GetSdPageCount( mePageKind ) );
+
+ // If in layer mode additionally show the layer that contains all
+ // selected shapes of the page. If the shapes are distributed on
+ // more than one layer, no layer name is shown.
+ if (IsLayerModeActive())
+ {
+ SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
+ SdrLayerID nLayer = 0, nOldLayer = 0;
+ SdrLayer* pLayer = NULL;
+ SdrObject* pObj = NULL;
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ sal_uLong nMarkCount = rMarkList.GetMarkCount();
+ FASTBOOL bOneLayer = sal_True;
+
+ // Use the first ten selected shapes as a (hopefully
+ // representative) sample of all shapes of the current page.
+ // Detect whether they belong to the same layer.
+ for( sal_uLong j = 0; j < nMarkCount && bOneLayer && j < 10; j++ )
+ {
+ pObj = rMarkList.GetMark( j )->GetMarkedSdrObj();
+ if( pObj )
+ {
+ nLayer = pObj->GetLayer();
+
+ if( j != 0 && nLayer != nOldLayer )
+ bOneLayer = sal_False;
+
+ nOldLayer = nLayer;
+ }
+ }
+
+ // Append the layer name to the current page number.
+ if( bOneLayer && nMarkCount )
+ {
+ pLayer = rLayerAdmin.GetLayerPerID( nLayer );
+ if( pLayer )
+ {
+ aString.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ));
+ aString += pLayer->GetName();
+ aString += sal_Unicode(')');
+ }
+ }
+ }
+
+ rSet.Put (SfxStringItem (SID_STATUS_PAGE, aString));
+ }
+ // Layout
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) )
+ {
+ String aString = mpActualPage->GetLayoutName();
+ aString.Erase( aString.SearchAscii( SD_LT_SEPARATOR ) );
+ rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aString ) );
+ }
+}
+
+
+
+void DrawViewShell::Notify (SfxBroadcaster&, const SfxHint& rHint)
+{
+ const SfxSimpleHint* pSimple = dynamic_cast< const SfxSimpleHint* >(&rHint);
+ if (pSimple!=NULL && pSimple->GetId()==SFX_HINT_MODECHANGED)
+ {
+ // Change to selection when turning on read-only mode.
+ if(GetDocSh()->IsReadOnly() && dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) )
+ {
+ SfxRequest aReq(SID_OBJECT_SELECT, 0, GetDoc()->GetItemPool());
+ FuPermanent(aReq);
+ }
+
+ // Turn on design mode when document is not read-only.
+ if (GetDocSh()->IsReadOnly() != mbReadOnly )
+ {
+ mbReadOnly = GetDocSh()->IsReadOnly();
+
+ SfxBoolItem aItem( SID_FM_DESIGN_MODE, !mbReadOnly );
+ GetViewFrame()->GetDispatcher()->Execute( SID_FM_DESIGN_MODE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+ }
+ }
+
+}
+
+void DrawViewShell::ExecuteAnnotation (SfxRequest& rRequest)
+{
+ if( mpAnnotationManager.get() )
+ mpAnnotationManager->ExecuteAnnotation( rRequest );
+}
+
+// --------------------------------------------------------------------
+
+void DrawViewShell::GetAnnotationState (SfxItemSet& rItemSet )
+{
+ if( mpAnnotationManager.get() )
+ mpAnnotationManager->GetAnnotationState( rItemSet );
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviewsb.cxx b/sd/source/ui/view/drviewsb.cxx
new file mode 100755
index 000000000000..eb3bb754698b
--- /dev/null
+++ b/sd/source/ui/view/drviewsb.cxx
@@ -0,0 +1,879 @@
+/*************************************************************************
+ *
+ * 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 <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <comphelper/processfactory.hxx>
+#include <svx/svdlayer.hxx>
+#ifndef _SVXIDS_HXX
+#include <svx/svxids.hrc>
+#endif
+#include <sfx2/msgpool.hxx>
+#include <svx/hyprlink.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/hlnkitem.hxx>
+#include <tools/urlobj.hxx>
+#include <editeng/eeitem.hxx>
+#ifndef _FLDITEM_HXX
+#include <editeng/flditem.hxx>
+#endif
+#include <vcl/msgbox.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/svdorect.hxx>
+#include <sfx2/docfile.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/sberrors.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <unotools/useroptions.hxx>
+
+#include "app.hrc"
+#include "strings.hrc"
+#include "res_bmp.hrc"
+#include "glob.hrc"
+#include "Outliner.hxx"
+#include "Window.hxx"
+#include "app.hxx"
+#include "sdattr.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "sdresid.hxx"
+#include "sdpage.hxx"
+#include "DrawViewShell.hxx"
+#include "drawview.hxx"
+#include "unmodpg.hxx"
+#include "undolayer.hxx"
+#include "ViewShellBase.hxx"
+#include "FormShellManager.hxx"
+#include "LayerTabBar.hxx"
+#include "sdabstdlg.hxx"
+#include "SlideSorterViewShell.hxx"
+#include "SlideSorter.hxx"
+#include "controller/SlideSorterController.hxx"
+
+#define RET_DELETE 100
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* SfxRequests fuer temporaere Funktionen
+|*
+\************************************************************************/
+
+void DrawViewShell::FuTemp02(SfxRequest& rReq)
+{
+ sal_uInt16 nSId = rReq.GetSlot();
+ switch( nSId )
+ {
+ case SID_INSERTLAYER:
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
+ sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
+ sal_uInt16 nLayer = nLayerCnt - 2 + 1;
+ String aLayerName ( SdResId(STR_LAYER) ), aLayerTitle, aLayerDesc;
+ aLayerName += String::CreateFromInt32( (sal_Int32)nLayer );
+ sal_Bool bIsVisible = sal_False;
+ sal_Bool bIsLocked = sal_False;
+ sal_Bool bIsPrintable = sal_False;
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if (! pArgs)
+ {
+ SfxItemSet aNewAttr( GetDoc()->GetPool(), ATTR_LAYER_START, ATTR_LAYER_END );
+
+ aNewAttr.Put( SdAttrLayerName( aLayerName ) );
+ aNewAttr.Put( SdAttrLayerTitle() );
+ aNewAttr.Put( SdAttrLayerDesc() );
+ aNewAttr.Put( SdAttrLayerVisible() );
+ aNewAttr.Put( SdAttrLayerPrintable() );
+ aNewAttr.Put( SdAttrLayerLocked() );
+ aNewAttr.Put( SdAttrLayerThisPage() );
+
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ AbstractSdInsertLayerDlg* pDlg = pFact ? pFact->CreateSdInsertLayerDlg(NULL, aNewAttr, true, String( SdResId( STR_INSERTLAYER ) ) ) : 0;
+ if( pDlg )
+ {
+ pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_INSERTLAYER )->GetCommand() );
+
+ // Ueberpruefung auf schon vorhandene Namen
+ sal_Bool bLoop = sal_True;
+ while( bLoop && pDlg->Execute() == RET_OK )
+ {
+ pDlg->GetAttr( aNewAttr );
+ aLayerName = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
+
+ if( rLayerAdmin.GetLayer( aLayerName, sal_False )
+ || aLayerName.Len()==0 )
+ {
+ // Name ist schon vorhanden
+ WarningBox aWarningBox (
+ GetParentWindow(),
+ WinBits( WB_OK ),
+ String(SdResId( STR_WARN_NAME_DUPLICATE)));
+ aWarningBox.Execute();
+ }
+ else
+ bLoop = sal_False;
+ }
+ if( bLoop ) // wurde abgebrochen
+ {
+ delete pDlg;
+
+ Cancel();
+ rReq.Ignore ();
+ break;
+ }
+ else
+ {
+ //pDlg->GetAttr( aNewAttr );
+ //aLayerName = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
+ aLayerTitle = ((SdAttrLayerTitle &) aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue ();
+ aLayerDesc = ((SdAttrLayerDesc &) aNewAttr.Get (ATTR_LAYER_DESC)).GetValue ();
+ bIsVisible = ((SdAttrLayerVisible &) aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
+ bIsLocked = ((SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue () ;
+ bIsPrintable = ((SdAttrLayerPrintable &) aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue () ;
+
+ delete pDlg;
+ }
+ }
+ }
+ else if (pArgs->Count () != 4)
+ {
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ Cancel();
+ rReq.Ignore ();
+ break;
+ }
+ else
+ {
+ SFX_REQUEST_ARG (rReq, pLayerName, SfxStringItem, ID_VAL_LAYERNAME, sal_False);
+ SFX_REQUEST_ARG (rReq, pIsVisible, SfxBoolItem, ID_VAL_ISVISIBLE, sal_False);
+ SFX_REQUEST_ARG (rReq, pIsLocked, SfxBoolItem, ID_VAL_ISLOCKED, sal_False);
+ SFX_REQUEST_ARG (rReq, pIsPrintable, SfxBoolItem, ID_VAL_ISPRINTABLE, sal_False);
+
+ aLayerName = pLayerName->GetValue ();
+ bIsVisible = pIsVisible->GetValue ();
+ bIsLocked = pIsLocked->GetValue ();
+ bIsPrintable = pIsPrintable->GetValue ();
+ }
+
+ String aPrevLayer = mpDrawView->GetActiveLayer();
+ String aName;
+ SdrLayer* pLayer;
+ sal_uInt16 nPrevLayer = 0;
+ nLayerCnt = rLayerAdmin.GetLayerCount();
+
+ for ( nLayer = 0; nLayer < nLayerCnt; nLayer++ )
+ {
+ pLayer = rLayerAdmin.GetLayer(nLayer);
+ aName = pLayer->GetName();
+
+ if ( aPrevLayer == aName )
+ {
+// nPrevLayer = nLayer;
+ nPrevLayer = Max(nLayer, (sal_uInt16) 4);
+ }
+ }
+
+ mpDrawView->InsertNewLayer(aLayerName, nPrevLayer + 1);
+ pLayer = rLayerAdmin.GetLayer(aLayerName, sal_False);
+ if( pLayer )
+ {
+ pLayer->SetTitle( aLayerTitle );
+ pLayer->SetDescription( aLayerDesc );
+ }
+
+ mpDrawView->SetLayerVisible( aLayerName, bIsVisible );
+ mpDrawView->SetLayerLocked( aLayerName, bIsLocked);
+ mpDrawView->SetLayerPrintable(aLayerName, bIsPrintable);
+
+ mpDrawView->SetActiveLayer(aLayerName);
+
+ ResetActualLayer();
+
+ GetDoc()->SetChanged(sal_True);
+
+ GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHLAYER,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_MODIFYLAYER:
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
+ sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId();
+ String aLayerName( GetLayerTabControl()->GetPageText(nCurPage) );
+ SdrLayer* pLayer = rLayerAdmin.GetLayer(aLayerName, sal_False);
+
+ String aLayerTitle( pLayer->GetTitle() );
+ String aLayerDesc( pLayer->GetDescription() );
+
+ String aOldLayerName( aLayerName );
+ String aOldLayerTitle( aLayerTitle );
+ String aOldLayerDesc( aLayerDesc );
+
+ sal_Bool bIsVisible, bIsLocked, bIsPrintable;
+ sal_Bool bOldIsVisible = bIsVisible = mpDrawView->IsLayerVisible(aLayerName);
+ sal_Bool bOldIsLocked = bIsLocked = mpDrawView->IsLayerLocked(aLayerName);
+ sal_Bool bOldIsPrintable = bIsPrintable = mpDrawView->IsLayerPrintable(aLayerName);
+
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ // darf der Layer geloescht werden ?
+ bool bDelete = true;
+
+ String aLayoutLayer ( SdResId(STR_LAYER_LAYOUT) );
+ String aControlsLayer ( SdResId(STR_LAYER_CONTROLS) );
+ String aMeasureLinesLayer ( SdResId(STR_LAYER_MEASURELINES) );
+ String aBackgroundLayer( SdResId(STR_LAYER_BCKGRND) );
+ String aBackgroundObjLayer( SdResId(STR_LAYER_BCKGRNDOBJ) );
+
+ if( aLayerName == aLayoutLayer || aLayerName == aControlsLayer ||
+ aLayerName == aMeasureLinesLayer ||
+ aLayerName == aBackgroundLayer || aLayerName == aBackgroundObjLayer )
+ {
+ bDelete = false;
+ }
+
+ if (! pArgs)
+ {
+ SfxItemSet aNewAttr( GetDoc()->GetPool(), ATTR_LAYER_START, ATTR_LAYER_END );
+
+ aNewAttr.Put( SdAttrLayerName( aLayerName ) );
+ aNewAttr.Put( SdAttrLayerTitle( aLayerTitle ) );
+ aNewAttr.Put( SdAttrLayerDesc( aLayerDesc ) );
+ aNewAttr.Put( SdAttrLayerVisible( bIsVisible ) );
+ aNewAttr.Put( SdAttrLayerLocked( bIsLocked ) );
+ aNewAttr.Put( SdAttrLayerPrintable( bIsPrintable ) );
+ aNewAttr.Put( SdAttrLayerThisPage() );
+
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ AbstractSdInsertLayerDlg* pDlg = pFact ? pFact->CreateSdInsertLayerDlg(NULL, aNewAttr, bDelete, String( SdResId( STR_MODIFYLAYER ) ) ) : 0;
+ if( pDlg )
+ {
+ pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_MODIFYLAYER )->GetCommand() );
+
+ // Ueberpruefung auf schon vorhandene Namen
+ sal_Bool bLoop = sal_True;
+ sal_uInt16 nRet = 0;
+ while( bLoop && ( (nRet = pDlg->Execute()) == RET_OK ) )
+ {
+ pDlg->GetAttr( aNewAttr );
+ aLayerName = ((SdAttrLayerName &) aNewAttr.Get (ATTR_LAYER_NAME)).GetValue ();
+
+ if( (rLayerAdmin.GetLayer( aLayerName, sal_False ) &&
+ aLayerName != aOldLayerName) || aLayerName.Len()==0 )
+ {
+ // Name ist schon vorhanden
+ WarningBox aWarningBox (
+ GetParentWindow(),
+ WinBits( WB_OK ),
+ String( SdResId( STR_WARN_NAME_DUPLICATE)));
+ aWarningBox.Execute();
+ }
+ else
+ bLoop = sal_False;
+ }
+ switch (nRet)
+ {
+ case RET_OK :
+ aLayerTitle = ((SdAttrLayerTitle &) aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue ();
+ aLayerDesc = ((SdAttrLayerDesc &) aNewAttr.Get (ATTR_LAYER_DESC)).GetValue ();
+ bIsVisible = ((const SdAttrLayerVisible &) aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
+ bIsLocked = ((const SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue ();
+ bIsPrintable = ((const SdAttrLayerLocked &) aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue ();
+
+ delete pDlg;
+ break;
+
+ default :
+ delete pDlg;
+ rReq.Ignore ();
+ Cancel ();
+ return;
+ }
+ }
+ }
+ else if (pArgs->Count () == 4)
+ {
+ SFX_REQUEST_ARG (rReq, pLayerName, SfxStringItem, ID_VAL_LAYERNAME, sal_False);
+ SFX_REQUEST_ARG (rReq, pIsVisible, SfxBoolItem, ID_VAL_ISVISIBLE, sal_False);
+ SFX_REQUEST_ARG (rReq, pIsLocked, SfxBoolItem, ID_VAL_ISLOCKED, sal_False);
+ SFX_REQUEST_ARG (rReq, pIsPrintable, SfxBoolItem, ID_VAL_ISPRINTABLE, sal_False);
+
+ aLayerName = pLayerName->GetValue ();
+ bIsVisible = pIsVisible->GetValue ();
+ bIsLocked = pIsLocked->GetValue ();
+ bIsPrintable = pIsPrintable->GetValue ();
+ }
+ else
+ {
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ Cancel ();
+ rReq.Ignore ();
+ break;
+ }
+
+ ::svl::IUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
+ SdLayerModifyUndoAction* pAction = new SdLayerModifyUndoAction(
+ GetDoc(),
+ pLayer,
+ // old values
+ aOldLayerName,
+ aOldLayerTitle,
+ aOldLayerDesc,
+ bOldIsVisible,
+ bOldIsLocked,
+ bOldIsPrintable,
+ // new values
+ aLayerName,
+ aLayerTitle,
+ aLayerDesc,
+ bIsVisible,
+ bIsLocked,
+ bIsPrintable
+ );
+ pManager->AddUndoAction( pAction );
+
+ ModifyLayer( pLayer, aLayerName, aLayerTitle, aLayerDesc, bIsVisible, bIsLocked, bIsPrintable );
+
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_RENAMELAYER:
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ GetLayerTabControl()->StartEditMode(
+ GetLayerTabControl()->GetCurPageId() );
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_EDIT_HYPERLINK :
+ {
+ GetViewFrame()->GetDispatcher()->Execute( SID_HYPERLINK_DIALOG );
+
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_OPEN_HYPERLINK:
+ {
+ OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
+ if ( pOutView )
+ {
+ const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection();
+ if ( pFieldItem )
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if( pField && pField->ISA( SvxURLField ) )
+ {
+ const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField );
+
+ SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() );
+ SfxStringItem aTarget( SID_TARGETNAME, pURLField->GetTargetFrame() );
+
+ String aReferName;
+ SfxViewFrame* pFrame = GetViewFrame();
+ SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
+ if (pMed)
+ aReferName = pMed->GetName();
+
+ SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
+ SfxStringItem aReferer( SID_REFERER, aReferName );
+
+ SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, sal_False );
+ SfxBoolItem aBrowsing( SID_BROWSE, sal_True );
+
+ SfxViewFrame* pViewFrm = SfxViewFrame::Current();
+ if (pViewFrm)
+ pViewFrm->GetDispatcher()->Execute( SID_OPENDOC,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aUrl, &aTarget,
+ &aFrm, &aReferer,
+ &aNewView, &aBrowsing,
+ 0L );
+ }
+ }
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_HYPERLINK_SETLINK:
+ {
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ if (pReqArgs)
+ {
+ SvxHyperlinkItem* pHLItem =
+ (SvxHyperlinkItem*) &pReqArgs->Get(SID_HYPERLINK_SETLINK);
+
+ if (pHLItem->GetInsertMode() == HLINK_FIELD)
+ {
+ InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
+ pHLItem->GetTargetFrame(), NULL);
+ }
+ else if (pHLItem->GetInsertMode() == HLINK_BUTTON)
+ {
+ InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
+ pHLItem->GetTargetFrame(), NULL);
+ }
+ else if (pHLItem->GetInsertMode() == HLINK_DEFAULT)
+ {
+ OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
+
+ if (pOlView)
+ {
+ InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
+ pHLItem->GetTargetFrame(), NULL);
+ }
+ else
+ {
+ InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
+ pHLItem->GetTargetFrame(), NULL);
+ }
+ }
+ }
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_INSERT_FLD_DATE_FIX:
+ case SID_INSERT_FLD_DATE_VAR:
+ case SID_INSERT_FLD_TIME_FIX:
+ case SID_INSERT_FLD_TIME_VAR:
+ case SID_INSERT_FLD_AUTHOR:
+ case SID_INSERT_FLD_PAGE:
+ case SID_INSERT_FLD_PAGES:
+ case SID_INSERT_FLD_FILE:
+ {
+ sal_uInt16 nMul = 1;
+ SvxFieldItem* pFieldItem = 0;
+
+ switch( nSId )
+ {
+ case SID_INSERT_FLD_DATE_FIX:
+ pFieldItem = new SvxFieldItem(
+ SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_DATE_VAR:
+ pFieldItem = new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_TIME_FIX:
+ pFieldItem = new SvxFieldItem(
+ SvxExtTimeField( Time(), SVXTIMETYPE_FIX ), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_TIME_VAR:
+ pFieldItem = new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_AUTHOR:
+ {
+ SvtUserOptions aUserOptions;
+ pFieldItem = new SvxFieldItem(
+ SvxAuthorField(
+ aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ), EE_FEATURE_FIELD );
+ }
+ break;
+
+ case SID_INSERT_FLD_PAGE:
+ {
+ pFieldItem = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD );
+ nMul = 3;
+ }
+ break;
+
+ case SID_INSERT_FLD_PAGES:
+ {
+ pFieldItem = new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD );
+ nMul = 3;
+ }
+ break;
+
+ case SID_INSERT_FLD_FILE:
+ {
+ String aName;
+ if( GetDocSh()->HasName() )
+ aName = GetDocSh()->GetMedium()->GetName();
+ //else
+ // aName = GetDocSh()->GetName();
+ pFieldItem = new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD );
+ }
+ break;
+ }
+
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+
+ if( pOLV )
+ {
+ const SvxFieldItem* pOldFldItem = pOLV->GetFieldAtSelection();
+
+ if( pOldFldItem && ( pOldFldItem->GetField()->ISA( SvxURLField ) ||
+ pOldFldItem->GetField()->ISA( SvxDateField ) ||
+ pOldFldItem->GetField()->ISA( SvxTimeField ) ||
+ pOldFldItem->GetField()->ISA( SvxExtTimeField ) ||
+ pOldFldItem->GetField()->ISA( SvxExtFileField ) ||
+ pOldFldItem->GetField()->ISA( SvxAuthorField ) ||
+ pOldFldItem->GetField()->ISA( SvxPageField ) ) )
+ {
+ // Feld selektieren, so dass es beim Insert geloescht wird
+ ESelection aSel = pOLV->GetSelection();
+ if( aSel.nStartPos == aSel.nEndPos )
+ aSel.nEndPos++;
+ pOLV->SetSelection( aSel );
+ }
+
+ if( pFieldItem )
+ pOLV->InsertField( *pFieldItem );
+ }
+ else
+ {
+ Outliner* pOutl = GetDoc()->GetInternalOutliner();
+ pOutl->Init( OUTLINERMODE_TEXTOBJECT );
+ sal_uInt16 nOutlMode = pOutl->GetMode();
+ pOutl->SetStyleSheet( 0, NULL );
+ pOutl->QuickInsertField( *pFieldItem, ESelection() );
+ OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject();
+
+ SdrRectObj* pRectObj = new SdrRectObj( OBJ_TEXT );
+ pRectObj->SetMergedItem(SdrTextAutoGrowWidthItem(sal_True));
+
+ pOutl->UpdateFields();
+ pOutl->SetUpdateMode( sal_True );
+ Size aSize( pOutl->CalcTextSize() );
+ aSize.Width() *= nMul;
+ pOutl->SetUpdateMode( sal_False );
+
+ Point aPos;
+ Rectangle aRect( aPos, GetActiveWindow()->GetOutputSizePixel() );
+ aPos = aRect.Center();
+ aPos = GetActiveWindow()->PixelToLogic(aPos);
+ aPos.X() -= aSize.Width() / 2;
+ aPos.Y() -= aSize.Height() / 2;
+
+ Rectangle aLogicRect(aPos, aSize);
+ pRectObj->SetLogicRect(aLogicRect);
+ pRectObj->SetOutlinerParaObject( pOutlParaObject );
+ mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
+ pOutl->Init( nOutlMode );
+ }
+
+ delete pFieldItem;
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_MODIFY_FIELD:
+ {
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+
+ if( pOLV )
+ {
+ const SvxFieldItem* pFldItem = pOLV->GetFieldAtSelection();
+
+ if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
+ pFldItem->GetField()->ISA( SvxAuthorField ) ||
+ pFldItem->GetField()->ISA( SvxExtFileField ) ||
+ pFldItem->GetField()->ISA( SvxExtTimeField ) ) )
+ {
+ // Dialog...
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ AbstractSdModifyFieldDlg* pDlg = pFact ? pFact->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem->GetField(), pOLV->GetAttribs() ) : 0;
+ if( pDlg && pDlg->Execute() == RET_OK )
+ {
+ // #108538#
+ // To make a correct SetAttribs() call at the utlinerView
+ // it is necessary to split the actions here
+ SvxFieldData* pField = pDlg->GetField();
+ ESelection aSel = pOLV->GetSelection();
+ sal_Bool bSelectionWasModified(sal_False);
+
+ if( pField )
+ {
+ SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
+
+ if( aSel.nStartPos == aSel.nEndPos )
+ {
+ bSelectionWasModified = sal_True;
+ aSel.nEndPos++;
+ pOLV->SetSelection( aSel );
+ }
+
+ pOLV->InsertField( aFieldItem );
+
+ // #108538# select again for eventual SetAttribs call
+ pOLV->SetSelection( aSel );
+ }
+
+ SfxItemSet aSet( pDlg->GetItemSet() );
+
+ if( aSet.Count() )
+ {
+ pOLV->SetAttribs( aSet );
+
+ ::Outliner* pOutliner = pOLV->GetOutliner();
+ if( pOutliner )
+ pOutliner->UpdateFields();
+ }
+
+ if(pField)
+ {
+ // #108538# restore selection to original
+ if(bSelectionWasModified)
+ {
+ aSel.nEndPos--;
+ pOLV->SetSelection( aSel );
+ }
+
+ delete pField;
+ }
+ }
+ delete pDlg;
+ }
+ }
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_OPEN_XML_FILTERSETTINGS:
+ {
+ try
+ {
+ com::sun::star::uno::Reference < ::com::sun::star::ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), com::sun::star::uno::UNO_QUERY);
+ if( xDialog.is() )
+ {
+ xDialog->execute();
+ }
+ }
+ catch( ::com::sun::star::uno::RuntimeException& )
+ {
+ }
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ default:
+ {
+ // switch Anweisung wegen CLOOKS aufgeteilt. Alle case-Anweisungen die
+ // eine Fu???? -Funktion aufrufen, sind in die Methode FuTemp03 (drviewsb)
+ // gewandert.
+ FuTemp03(rReq);
+ }
+ break;
+ };
+};
+
+bool DrawViewShell::RenameSlide( sal_uInt16 nPageId, const String & rName )
+{
+ sal_Bool bOutDummy;
+ if( GetDoc()->GetPageByName( rName, bOutDummy ) != SDRPAGE_NOTFOUND )
+ return false;
+
+ SdPage* pPageToRename = NULL;
+ PageKind ePageKind = GetPageKind();
+
+ if( GetEditMode() == EM_PAGE )
+ {
+ pPageToRename = GetDoc()->GetSdPage( nPageId - 1, ePageKind );
+
+ // Undo
+ SdPage* pUndoPage = pPageToRename;
+ SdrLayerAdmin & rLayerAdmin = GetDoc()->GetLayerAdmin();
+ sal_uInt8 nBackground = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRND )), sal_False );
+ sal_uInt8 nBgObj = rLayerAdmin.GetLayerID( String( SdResId( STR_LAYER_BCKGRNDOBJ )), sal_False );
+ SetOfByte aVisibleLayers = mpActualPage->TRG_GetMasterPageVisibleLayers();
+
+ // (#67720#)
+ ::svl::IUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
+ ModifyPageUndoAction* pAction = new ModifyPageUndoAction(
+ GetDoc(), pUndoPage, rName, pUndoPage->GetAutoLayout(),
+ aVisibleLayers.IsSet( nBackground ),
+ aVisibleLayers.IsSet( nBgObj ));
+ pManager->AddUndoAction( pAction );
+
+ // rename
+ pPageToRename->SetName( rName );
+
+ if( ePageKind == PK_STANDARD )
+ {
+ // also rename notes-page
+ SdPage* pNotesPage = GetDoc()->GetSdPage( nPageId - 1, PK_NOTES );
+ pNotesPage->SetName( rName );
+ }
+ }
+ else
+ {
+ // rename MasterPage -> rename LayoutTemplate
+ pPageToRename = GetDoc()->GetMasterSdPage( nPageId - 1, ePageKind );
+ GetDoc()->RenameLayoutTemplate( pPageToRename->GetLayoutName(), rName );
+ }
+
+ bool bSuccess = ( sal_False != rName.Equals( pPageToRename->GetName()));
+
+ if( bSuccess )
+ {
+ // user edited page names may be changed by the page so update control
+ maTabControl.SetPageText( nPageId, rName );
+
+ // set document to modified state
+ GetDoc()->SetChanged( sal_True );
+
+ // inform navigator about change
+ SfxBoolItem aItem( SID_NAVIGATOR_INIT, sal_True );
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_NAVIGATOR_INIT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+
+ // Tell the slide sorter about the name change (necessary for
+ // accessibility.)
+ slidesorter::SlideSorterViewShell* pSlideSorterViewShell
+ = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
+ if (pSlideSorterViewShell != NULL)
+ {
+ pSlideSorterViewShell->GetSlideSorter().GetController().PageNameHasChanged(
+ nPageId-1, rName);
+ }
+ }
+
+ return bSuccess;
+}
+
+
+
+
+IMPL_LINK( DrawViewShell, RenameSlideHdl, AbstractSvxNameDialog*, pDialog )
+{
+ if( ! pDialog )
+ return 0;
+
+ String aNewName;
+ pDialog->GetName( aNewName );
+
+ SdPage* pCurrentPage = GetDoc()->GetSdPage( maTabControl.GetCurPageId() - 1, GetPageKind() );
+
+ return pCurrentPage && ( aNewName.Equals( pCurrentPage->GetName() ) || GetDocSh()->IsNewPageNameValid( aNewName ) );
+}
+
+
+
+
+void DrawViewShell::ModifyLayer (
+ SdrLayer* pLayer,
+ const String& rLayerName,
+ const String& rLayerTitle,
+ const String& rLayerDesc,
+ bool bIsVisible,
+ bool bIsLocked,
+ bool bIsPrintable)
+{
+ if( pLayer )
+ {
+ const sal_uInt16 nPageCount = GetLayerTabControl()->GetPageCount();
+ sal_uInt16 nCurPage = 0;
+ sal_uInt16 nPos;
+ for( nPos = 0; nPos < nPageCount; nPos++ )
+ {
+ sal_uInt16 nId = GetLayerTabControl()->GetPageId( nPos );
+ if( pLayer->GetName() == GetLayerTabControl()->GetPageText( nId ) )
+ {
+ nCurPage = nId;
+ break;
+ }
+ }
+
+ pLayer->SetName( rLayerName );
+ pLayer->SetTitle( rLayerTitle );
+ pLayer->SetDescription( rLayerDesc );
+ mpDrawView->SetLayerVisible( rLayerName, bIsVisible );
+ mpDrawView->SetLayerLocked( rLayerName, bIsLocked);
+ mpDrawView->SetLayerPrintable(rLayerName, bIsPrintable);
+
+ GetDoc()->SetChanged(sal_True);
+
+ GetLayerTabControl()->SetPageText(nCurPage, rLayerName);
+
+ TabBarPageBits nBits = 0;
+
+ if (!bIsVisible)
+ {
+ // Unsichtbare Layer werden anders dargestellt
+ nBits = TPB_SPECIAL;
+ }
+
+ GetLayerTabControl()->SetPageBits(nCurPage, nBits);
+
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_SWITCHLAYER,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+
+ // Call Invalidate at the form shell.
+ FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
+ if (pFormShell != NULL)
+ pFormShell->Invalidate();
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviewsc.cxx b/sd/source/ui/view/drviewsc.cxx
new file mode 100755
index 000000000000..5d629c00ed49
--- /dev/null
+++ b/sd/source/ui/view/drviewsc.cxx
@@ -0,0 +1,990 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include "ViewShellImplementation.hxx"
+#include <vcl/waitobj.hxx>
+
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svx/dialogs.hrc>
+#ifndef _IMAPDLG_HXX
+#include <svx/imapdlg.hxx>
+#endif
+#include <vcl/msgbox.hxx>
+#include <sfx2/request.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svxdlg.hxx>
+#ifndef _BINDING_HXX //autogen
+#include <sfx2/bindings.hxx>
+#endif
+#include <sfx2/dispatch.hxx>
+#include <svx/svdoole2.hxx>
+#include <svl/style.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/grafctrl.hxx>
+#include "stlsheet.hxx"
+
+#include <sfx2/viewfrm.hxx>
+
+#include "app.hrc"
+#include "strings.hrc"
+#include "helpids.h"
+#include "misc.hxx"
+#include "Window.hxx"
+#include "imapinfo.hxx"
+#include "futempl.hxx"
+#include "fusel.hxx"
+#include "sdresid.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "drawview.hxx"
+#include "sdabstdlg.hxx"
+#include "brkdlg.hrc"
+namespace sd {
+
+#define MIN_ACTIONS_FOR_DIALOG 5000 // bei mehr als 1600 Metaobjekten
+ // wird beim Aufbrechen ein Dialog
+ // angezeigt.
+/*************************************************************************
+|*
+|* SfxRequests fuer temporaere Funktionen
+|*
+\************************************************************************/
+
+void DrawViewShell::FuTemp03(SfxRequest& rReq)
+{
+ sal_uInt16 nSId = rReq.GetSlot();
+ switch( nSId )
+ {
+ case SID_GROUP: // BASIC
+ {
+ if ( mpDrawView->IsPresObjSelected( sal_True, sal_True, sal_True ) )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ mpDrawView->GroupMarked();
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_UNGROUP: // BASIC
+ {
+ mpDrawView->UnGroupMarked();
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_NAME_GROUP:
+ {
+ // only allow for single object selection since the name of an object needs
+ // to be unique
+ if(1L == mpDrawView->GetMarkedObjectCount())
+ {
+ // #i68101#
+ SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0L);
+ OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
+ String aName(pSelected->GetName());
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ pDlg->SetCheckNameHdl(LINK(this, DrawViewShell, NameObjectHdl));
+
+ if(RET_OK == pDlg->Execute())
+ {
+ pDlg->GetName(aName);
+ pSelected->SetName(aName);
+ }
+
+ delete pDlg;
+ }
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_NAVIGATOR_STATE, sal_True, sal_False );
+ rBindings.Invalidate( SID_CONTEXT );
+
+ Cancel();
+ rReq.Ignore();
+ break;
+ }
+
+ // #i68101#
+ case SID_OBJECT_TITLE_DESCRIPTION:
+ {
+ if(1L == mpDrawView->GetMarkedObjectCount())
+ {
+ SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0L);
+ OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
+ String aTitle(pSelected->GetTitle());
+ String aDescription(pSelected->GetDescription());
+
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "Dialogdiet fail!");
+ AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
+ OSL_ENSURE(pDlg, "Dialogdiet fail!");
+
+ if(RET_OK == pDlg->Execute())
+ {
+ pDlg->GetTitle(aTitle);
+ pDlg->GetDescription(aDescription);
+ pSelected->SetTitle(aTitle);
+ pSelected->SetDescription(aDescription);
+ }
+
+ delete pDlg;
+ }
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_NAVIGATOR_STATE, sal_True, sal_False );
+ rBindings.Invalidate( SID_CONTEXT );
+
+ Cancel();
+ rReq.Ignore();
+ break;
+ }
+
+ case SID_ENTER_GROUP: // BASIC
+ {
+ mpDrawView->EnterMarkedGroup();
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_LEAVE_GROUP: // BASIC
+ {
+ mpDrawView->LeaveOneGroup();
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_LEAVE_ALL_GROUPS: // BASIC
+ {
+ mpDrawView->LeaveAllGroup();
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_COMBINE: // BASIC
+ {
+ // #88224# End text edit to avoid conflicts
+ if(mpDrawView->IsTextEdit())
+ mpDrawView->SdrEndTextEdit();
+
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->CombineMarkedObjects(sal_False);
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_DISTRIBUTE_DLG:
+ {
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ mpDrawView->DistributeMarkedObjects();
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_POLY_MERGE:
+ {
+ // #88224# End text edit to avoid conflicts
+ if(mpDrawView->IsTextEdit())
+ mpDrawView->SdrEndTextEdit();
+
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->MergeMarkedObjects(SDR_MERGE_MERGE);
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_POLY_SUBSTRACT:
+ {
+ // #88224# End text edit to avoid conflicts
+ if(mpDrawView->IsTextEdit())
+ mpDrawView->SdrEndTextEdit();
+
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->MergeMarkedObjects(SDR_MERGE_SUBSTRACT);
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_POLY_INTERSECT:
+ {
+ // #88224# End text edit to avoid conflicts
+ if(mpDrawView->IsTextEdit())
+ mpDrawView->SdrEndTextEdit();
+
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->MergeMarkedObjects(SDR_MERGE_INTERSECT);
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_DISMANTLE: // BASIC
+ {
+ if ( mpDrawView->IsDismantlePossible(sal_False) )
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->DismantleMarkedObjects(sal_False);
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_CONNECT: // BASIC
+ {
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->CombineMarkedObjects(sal_True);
+ }
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_BREAK: // BASIC
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ if ( mpDrawView->IsBreak3DObjPossible() )
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->Break3DObj();
+ }
+ else if ( mpDrawView->IsDismantlePossible(sal_True) )
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->DismantleMarkedObjects(sal_True);
+ }
+ else if ( mpDrawView->IsImportMtfPossible() )
+ {
+
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ sal_uLong nAnz=rMarkList.GetMarkCount();
+
+ // Summe der Metaobjekte aller sel. Metafiles erm.
+ sal_uLong nCount = 0;
+ for(sal_uLong nm=0; nm<nAnz; nm++)
+ {
+ SdrMark* pM=rMarkList.GetMark(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ SdrGrafObj* pGraf=PTR_CAST(SdrGrafObj,pObj);
+ SdrOle2Obj* pOle2=PTR_CAST(SdrOle2Obj,pObj);
+ if (pGraf!=NULL && pGraf->HasGDIMetaFile())
+ nCount += pGraf->GetGraphic().GetGDIMetaFile().GetActionCount();
+ if(pOle2!=NULL && pOle2->GetGraphic())
+ nCount += pOle2->GetGraphic()->GetGDIMetaFile().GetActionCount();
+ }
+
+ // anhand der erm. Summe entscheiden ob mit
+ // oder ohne Dialog aufgebrochen wird.
+ if(nCount < MIN_ACTIONS_FOR_DIALOG)
+ {
+ // ohne Dialog aufbrechen
+ mpDrawView->DoImportMarkedMtf();
+ }
+ else
+ {
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ if( pFact )
+ {
+ VclAbstractDialog* pDlg = pFact->CreateBreakDlg(GetActiveWindow(), mpDrawView, GetDocSh(), nCount, nAnz );
+ if( pDlg )
+ {
+ pDlg->Execute();
+ delete pDlg;
+ }
+ }
+ }
+ }
+
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_CONVERT_TO_3D:
+ {
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ if (mpDrawView->IsConvertTo3DObjPossible())
+ {
+ if (mpDrawView->IsTextEdit())
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->ConvertMarkedObjTo3D(sal_True);
+ }
+ }
+
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_FRAME_TO_TOP: // BASIC
+ {
+ mpDrawView->PutMarkedToTop();
+ Cancel();
+ Invalidate( SID_POSITION );
+ rReq.Done ();
+ }
+ break;
+
+ case SID_MOREFRONT: // BASIC
+ {
+ mpDrawView->MovMarkedToTop();
+ Cancel();
+ Invalidate( SID_POSITION );
+ rReq.Done ();
+ }
+ break;
+
+ case SID_MOREBACK: // BASIC
+ {
+ mpDrawView->MovMarkedToBtm();
+ Cancel();
+ Invalidate( SID_POSITION );
+ rReq.Done ();
+ }
+ break;
+
+ case SID_FRAME_TO_BOTTOM: // BASIC
+ {
+ mpDrawView->PutMarkedToBtm();
+ Cancel();
+ Invalidate( SID_POSITION );
+ rReq.Done ();
+ }
+ break;
+
+ case SID_HORIZONTAL: // BASIC
+ {
+ mpDrawView->MirrorAllMarkedHorizontal();
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_VERTICAL: // BASIC
+ {
+ mpDrawView->MirrorAllMarkedVertical();
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_OBJECT_ALIGN_LEFT: // BASIC
+ {
+ mpDrawView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE);
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_OBJECT_ALIGN_CENTER: // BASIC
+ {
+ mpDrawView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE);
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_OBJECT_ALIGN_RIGHT: // BASIC
+ {
+ mpDrawView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE);
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_OBJECT_ALIGN_UP: // BASIC
+ {
+ mpDrawView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP);
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_OBJECT_ALIGN_MIDDLE: // BASIC
+ {
+ mpDrawView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER);
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_OBJECT_ALIGN_DOWN: // BASIC
+ {
+ mpDrawView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM);
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_SELECTALL: // BASIC
+ {
+ if( (dynamic_cast<FuSelection*>( GetOldFunction().get() ) != 0) &&
+ !GetView()->IsFrameDragSingles() && GetView()->HasMarkablePoints())
+ {
+ if ( !mpDrawView->IsAction() )
+ mpDrawView->MarkAllPoints();
+ }
+ else
+ mpDrawView->SelectAll();
+
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_STYLE_NEW: // BASIC ???
+ case SID_STYLE_APPLY:
+ case SID_STYLE_EDIT:
+ case SID_STYLE_DELETE:
+ case SID_STYLE_FAMILY:
+ case SID_STYLE_WATERCAN:
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ if( rReq.GetSlot() == SID_STYLE_EDIT && !rReq.GetArgs() )
+ {
+ SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
+ if( pStyleSheet && pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
+ pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
+
+ if( (pStyleSheet == NULL) && GetView()->IsTextEdit() )
+ {
+ GetView()->SdrEndTextEdit();
+
+ pStyleSheet = mpDrawView->GetStyleSheet();
+ if(pStyleSheet && pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
+ pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
+ }
+
+ if( pStyleSheet == NULL )
+ {
+ rReq.Ignore();
+ break;
+ }
+
+ SfxAllItemSet aSet(GetDoc()->GetPool());
+
+ SfxStringItem aStyleNameItem( SID_STYLE_EDIT, pStyleSheet->GetName() );
+ aSet.Put(aStyleNameItem);
+
+ SfxUInt16Item aStyleFamilyItem( SID_STYLE_FAMILY, (sal_uInt16)pStyleSheet->GetFamily() );
+ aSet.Put(aStyleFamilyItem);
+
+ rReq.SetArgs(aSet);
+ }
+
+ if( rReq.GetArgs() )
+ {
+ SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ if( rReq.GetSlot() == SID_STYLE_APPLY )
+ GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY );
+ Cancel();
+ }
+ else if( rReq.GetSlot() == SID_STYLE_APPLY )
+ GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER, SFX_CALLMODE_ASYNCHRON );
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_IMAP:
+ {
+ SvxIMapDlg* pDlg;
+ sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
+
+ GetViewFrame()->ToggleChildWindow( nId );
+ GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
+
+ if ( GetViewFrame()->HasChildWindow( nId )
+ && ( ( pDlg = ViewShell::Implementation::GetImageMapDialog() ) != NULL ) )
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+
+ if ( rMarkList.GetMarkCount() == 1 )
+ UpdateIMapDlg( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
+ }
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_GRID_FRONT:
+ {
+ mpDrawView->SetGridFront( !mpDrawView->IsGridFront() );
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_HELPLINES_FRONT:
+ {
+ mpDrawView->SetHlplFront( !mpDrawView->IsHlplFront() );
+ Cancel();
+ rReq.Done ();
+ }
+ break;
+
+ default:
+ FuTemp04(rReq);
+ break;
+ };
+};
+
+/*************************************************************************
+|*
+|* Liefert die globale/Haupt-ID zurueck, also die ID, ueber die die
+|* Toolbox ausgeloest wird
+|*
+\************************************************************************/
+
+sal_uInt16 DrawViewShell::GetIdBySubId( sal_uInt16 nSId )
+{
+ sal_uInt16 nMappedSId = 0;
+ switch( nSId )
+ {
+ case SID_OBJECT_ROTATE:
+ case SID_OBJECT_MIRROR:
+ case SID_OBJECT_TRANSPARENCE:
+ case SID_OBJECT_GRADIENT:
+ case SID_OBJECT_SHEAR:
+ case SID_OBJECT_CROOK_ROTATE:
+ case SID_OBJECT_CROOK_SLANT:
+ case SID_OBJECT_CROOK_STRETCH:
+ case SID_CONVERT_TO_3D_LATHE:
+ {
+ nMappedSId = SID_OBJECT_CHOOSE_MODE;
+ }
+ break;
+
+ case SID_OBJECT_ALIGN_LEFT:
+ case SID_OBJECT_ALIGN_CENTER:
+ case SID_OBJECT_ALIGN_RIGHT:
+ case SID_OBJECT_ALIGN_UP:
+ case SID_OBJECT_ALIGN_MIDDLE:
+ case SID_OBJECT_ALIGN_DOWN:
+ {
+ nMappedSId = SID_OBJECT_ALIGN;
+ }
+ break;
+
+ case SID_FRAME_TO_TOP:
+ case SID_MOREFRONT:
+ case SID_MOREBACK:
+ case SID_FRAME_TO_BOTTOM:
+ case SID_BEFORE_OBJ:
+ case SID_BEHIND_OBJ:
+ case SID_REVERSE_ORDER:
+ {
+ nMappedSId = SID_POSITION;
+ }
+ break;
+
+ case SID_ZOOM_OUT:
+ case SID_ZOOM_IN:
+ case SID_SIZE_REAL:
+ case SID_ZOOM_PANNING:
+ case SID_SIZE_PAGE:
+ case SID_SIZE_PAGE_WIDTH:
+ case SID_SIZE_ALL:
+ case SID_SIZE_OPTIMAL:
+ case SID_ZOOM_NEXT:
+ case SID_ZOOM_PREV:
+ {
+ nMappedSId = SID_ZOOM_TOOLBOX;
+ }
+ break;
+
+ case SID_ATTR_CHAR:
+ case SID_TEXT_FITTOSIZE:
+ case SID_DRAW_CAPTION:
+ case SID_DRAW_FONTWORK:
+ case SID_DRAW_FONTWORK_VERTICAL:
+ {
+ nMappedSId = SID_DRAWTBX_TEXT;
+ }
+ break;
+
+ case SID_DRAW_RECT:
+ case SID_DRAW_SQUARE:
+ case SID_DRAW_RECT_ROUND:
+ case SID_DRAW_SQUARE_ROUND:
+ case SID_DRAW_RECT_NOFILL:
+ case SID_DRAW_SQUARE_NOFILL:
+ case SID_DRAW_RECT_ROUND_NOFILL:
+ case SID_DRAW_SQUARE_ROUND_NOFILL:
+ {
+ nMappedSId = SID_DRAWTBX_RECTANGLES;
+ }
+ break;
+
+ case SID_DRAW_ELLIPSE:
+ case SID_DRAW_CIRCLE:
+ case SID_DRAW_PIE:
+ case SID_DRAW_CIRCLEPIE:
+ case SID_DRAW_ELLIPSECUT:
+ case SID_DRAW_CIRCLECUT:
+ case SID_DRAW_ARC:
+ case SID_DRAW_CIRCLEARC:
+ case SID_DRAW_ELLIPSE_NOFILL:
+ case SID_DRAW_CIRCLE_NOFILL:
+ case SID_DRAW_PIE_NOFILL:
+ case SID_DRAW_CIRCLEPIE_NOFILL:
+ case SID_DRAW_ELLIPSECUT_NOFILL:
+ case SID_DRAW_CIRCLECUT_NOFILL:
+ {
+ nMappedSId = SID_DRAWTBX_ELLIPSES;
+ }
+ break;
+
+ case SID_DRAW_BEZIER_NOFILL:
+ case SID_DRAW_POLYGON_NOFILL:
+ case SID_DRAW_XPOLYGON_NOFILL:
+ case SID_DRAW_FREELINE_NOFILL:
+ case SID_DRAW_BEZIER_FILL:
+ case SID_DRAW_POLYGON:
+ case SID_DRAW_XPOLYGON:
+ case SID_DRAW_FREELINE:
+ {
+ nMappedSId = SID_DRAWTBX_LINES;
+ }
+ break;
+
+ case SID_DRAW_LINE:
+ case SID_DRAW_XLINE:
+ case SID_DRAW_MEASURELINE:
+ case SID_LINE_ARROW_START:
+ case SID_LINE_ARROW_END:
+ case SID_LINE_ARROWS:
+ case SID_LINE_ARROW_CIRCLE:
+ case SID_LINE_CIRCLE_ARROW:
+ case SID_LINE_ARROW_SQUARE:
+ case SID_LINE_SQUARE_ARROW:
+ {
+ nMappedSId = SID_DRAWTBX_ARROWS;
+ }
+ break;
+
+ case SID_3D_CUBE:
+ case SID_3D_TORUS:
+ case SID_3D_SPHERE:
+ case SID_3D_SHELL:
+ case SID_3D_HALF_SPHERE:
+ case SID_3D_CYLINDER:
+ case SID_3D_CONE:
+ case SID_3D_PYRAMID:
+ {
+ nMappedSId = SID_DRAWTBX_3D_OBJECTS;
+ }
+ break;
+
+ case SID_INSERT_DIAGRAM:
+ case SID_ATTR_TABLE:
+ case SID_INSERTFILE:
+ case SID_INSERT_GRAPHIC:
+ case SID_INSERT_AVMEDIA:
+ case SID_INSERTPAGE:
+ case SID_INSERT_MATH:
+ case SID_INSERT_FLOATINGFRAME:
+ case SID_INSERT_OBJECT:
+ case SID_INSERT_PLUGIN:
+ case SID_INSERT_SOUND:
+ case SID_INSERT_VIDEO:
+ case SID_INSERT_TABLE:
+ {
+ nMappedSId = SID_DRAWTBX_INSERT;
+ }
+ break;
+
+ case SID_TOOL_CONNECTOR:
+ case SID_CONNECTOR_ARROW_START:
+ case SID_CONNECTOR_ARROW_END:
+ case SID_CONNECTOR_ARROWS:
+ case SID_CONNECTOR_CIRCLE_START:
+ case SID_CONNECTOR_CIRCLE_END:
+ case SID_CONNECTOR_CIRCLES:
+ case SID_CONNECTOR_LINE:
+ case SID_CONNECTOR_LINE_ARROW_START:
+ case SID_CONNECTOR_LINE_ARROW_END:
+ case SID_CONNECTOR_LINE_ARROWS:
+ case SID_CONNECTOR_LINE_CIRCLE_START:
+ case SID_CONNECTOR_LINE_CIRCLE_END:
+ case SID_CONNECTOR_LINE_CIRCLES:
+ case SID_CONNECTOR_CURVE:
+ case SID_CONNECTOR_CURVE_ARROW_START:
+ case SID_CONNECTOR_CURVE_ARROW_END:
+ case SID_CONNECTOR_CURVE_ARROWS:
+ case SID_CONNECTOR_CURVE_CIRCLE_START:
+ case SID_CONNECTOR_CURVE_CIRCLE_END:
+ case SID_CONNECTOR_CURVE_CIRCLES:
+ case SID_CONNECTOR_LINES:
+ case SID_CONNECTOR_LINES_ARROW_START:
+ case SID_CONNECTOR_LINES_ARROW_END:
+ case SID_CONNECTOR_LINES_ARROWS:
+ case SID_CONNECTOR_LINES_CIRCLE_START:
+ case SID_CONNECTOR_LINES_CIRCLE_END:
+ case SID_CONNECTOR_LINES_CIRCLES:
+ {
+ nMappedSId = SID_DRAWTBX_CONNECTORS;
+ }
+ }
+ return( nMappedSId );
+}
+
+/*************************************************************************
+|*
+|* Fuellt das SlotArray, um das aktuelle Mapping des ToolboxSlots zu
+|* bekommen
+|*
+\************************************************************************/
+
+void DrawViewShell::MapSlot( sal_uInt16 nSId )
+{
+ sal_uInt16 nMappedSId = GetIdBySubId( nSId );
+
+ if( nMappedSId > 0 )
+ {
+ sal_uInt16 nID = GetArrayId( nMappedSId ) + 1;
+ mpSlotArray[ nID ] = nSId;
+ }
+}
+
+/*************************************************************************
+|*
+|* Ermoeglicht ueber das SlotArray ein ImageMapping
+|*
+\************************************************************************/
+
+void DrawViewShell::UpdateToolboxImages( SfxItemSet &rSet, sal_Bool bPermanent )
+{
+ if( !bPermanent )
+ {
+ sal_uInt16 nId = GetArrayId( SID_ZOOM_TOOLBOX ) + 1;
+ rSet.Put( TbxImageItem( SID_ZOOM_TOOLBOX, mpSlotArray[nId] ) );
+
+ nId = GetArrayId( SID_DRAWTBX_INSERT ) + 1;
+ rSet.Put( TbxImageItem( SID_DRAWTBX_INSERT, mpSlotArray[nId] ) );
+
+ nId = GetArrayId( SID_POSITION ) + 1;
+ rSet.Put( TbxImageItem( SID_POSITION, mpSlotArray[nId] ) );
+
+ nId = GetArrayId( SID_OBJECT_ALIGN ) + 1;
+ rSet.Put( TbxImageItem( SID_OBJECT_ALIGN, mpSlotArray[nId] ) );
+ }
+ else
+ {
+ for( sal_uInt16 nId = 0; nId < SLOTARRAY_COUNT; nId += 2 )
+ {
+ rSet.Put( TbxImageItem( mpSlotArray[nId], mpSlotArray[nId+1] ) );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* Gibt den gemappten Slot zurueck
+|*
+\************************************************************************/
+
+sal_uInt16 DrawViewShell::GetMappedSlot( sal_uInt16 nSId )
+{
+ sal_uInt16 nSlot = 0;
+ sal_uInt16 nId = GetArrayId( nSId );
+ if( nId != USHRT_MAX )
+ nSlot = mpSlotArray[ nId+1 ];
+
+ // Wenn der Slot noch auf sich selbst gemapped ist, muss 0 zurueck-
+ // gegeben werden, da sonst der Slot immer wieder selbst executet
+ // wird. Im Array ist der Slot selbst initial vorhanden, damit das
+ // Image richtig angezeigt wird.
+ if( nSId == nSlot )
+ return( 0 );
+
+ return( nSlot );
+}
+
+/*************************************************************************
+|*
+|* Gibt die Nummer des HauptSlots im SlotArray zurueck
+|*
+\************************************************************************/
+
+sal_uInt16 DrawViewShell::GetArrayId( sal_uInt16 nSId )
+{
+ for( sal_uInt16 i = 0; i < SLOTARRAY_COUNT; i += 2 )
+ {
+ if( mpSlotArray[ i ] == nSId )
+ return( i );
+ }
+ DBG_ERROR( "Slot im Array nicht gefunden!" );
+ return( USHRT_MAX );
+}
+
+
+/*************************************************************************
+|*
+|* IMap-Dlg updaten
+|*
+\************************************************************************/
+
+void DrawViewShell::UpdateIMapDlg( SdrObject* pObj )
+{
+ if( ( pObj->ISA( SdrGrafObj ) || pObj->ISA( SdrOle2Obj ) ) && !mpDrawView->IsTextEdit() &&
+ GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
+ {
+ Graphic aGraphic;
+ ImageMap* pIMap = NULL;
+ TargetList* pTargetList = NULL;
+ SdIMapInfo* pIMapInfo = GetDoc()->GetIMapInfo( pObj );
+
+ // get graphic from shape
+ SdrGrafObj* pGrafObj = dynamic_cast< SdrGrafObj* >( pObj );
+ if( pGrafObj )
+ aGraphic = pGrafObj->GetGraphic();
+
+ if ( pIMapInfo )
+ {
+ pIMap = (ImageMap*) &pIMapInfo->GetImageMap();
+ pTargetList = new TargetList;
+ GetViewFrame()->GetTargetList( *pTargetList );
+ }
+
+ SvxIMapDlgChildWindow::UpdateIMapDlg( aGraphic, pIMap, pTargetList, pObj );
+
+ // TargetListe kann von uns wieder geloescht werden
+ if ( pTargetList )
+ {
+ String* pEntry = pTargetList->First();
+ while( pEntry )
+ {
+ delete pEntry;
+ pEntry = pTargetList->Next();
+ }
+
+ delete pTargetList;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( DrawViewShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog )
+{
+ String aName;
+
+ if( pDialog )
+ pDialog->GetName( aName );
+
+ return( ( !aName.Len() || ( GetDoc() && !GetDoc()->GetObj( aName ) ) ) ? 1 : 0 );
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviewsd.cxx b/sd/source/ui/view/drviewsd.cxx
new file mode 100755
index 000000000000..c8b5c1939133
--- /dev/null
+++ b/sd/source/ui/view/drviewsd.cxx
@@ -0,0 +1,259 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svl/aeitem.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/intitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+
+#include <sfx2/viewfrm.hxx>
+
+
+#include "app.hrc"
+
+#include "sdpage.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "slideshow.hxx"
+#include "pgjump.hxx"
+#include "NavigatorChildWindow.hxx"
+#ifndef SD_NAVIGATION_HXX
+#include "navigatr.hxx"
+#endif
+#include "drawview.hxx"
+#include "slideshow.hxx"
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Navigator bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecNavigatorWin( SfxRequest& rReq )
+{
+ CheckLineTo (rReq);
+
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ switch( nSId )
+ {
+ case SID_NAVIGATOR_INIT:
+ {
+ sal_uInt16 nId = SID_NAVIGATOR;
+ SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
+ if( pWindow )
+ {
+ SdNavigatorWin* pNavWin = (SdNavigatorWin*)( pWindow->GetContextWindow( SD_MOD() ) );
+ if( pNavWin )
+ pNavWin->InitTreeLB( GetDoc() );
+ }
+ }
+ break;
+
+ case SID_NAVIGATOR_PEN:
+ case SID_NAVIGATOR_PAGE:
+ case SID_NAVIGATOR_OBJECT:
+ {
+ rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if (xSlideshow.is() && xSlideshow->isRunning() )
+ {
+ xSlideshow->receiveRequest( rReq );
+ }
+ else if (nSId == SID_NAVIGATOR_PAGE)
+ {
+ if ( mpDrawView->IsTextEdit() )
+ mpDrawView->SdrEndTextEdit();
+
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ PageJump eJump = (PageJump)((SfxAllEnumItem&) pArgs->
+ Get(SID_NAVIGATOR_PAGE)).GetValue();
+
+ switch (eJump)
+ {
+ case PAGE_FIRST:
+ {
+ // Sprung zu erster Seite
+ SwitchPage(0);
+ }
+ break;
+
+ case PAGE_LAST:
+ {
+ // Sprung zu letzter Seite
+ SwitchPage(GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1);
+ }
+ break;
+
+ case PAGE_NEXT:
+ {
+ // Sprung zu naechster Seite
+ sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
+
+ if (nSdPage < GetDoc()->GetSdPageCount(mpActualPage->GetPageKind()) - 1)
+ {
+ SwitchPage(nSdPage + 1);
+ }
+ }
+ break;
+
+ case PAGE_PREVIOUS:
+ {
+ // Sprung zu vorheriger Seite
+ sal_uInt16 nSdPage = (mpActualPage->GetPageNum() - 1) / 2;
+
+ if (nSdPage > 0)
+ {
+ SwitchPage(nSdPage - 1);
+ }
+ }
+ break;
+
+ case PAGE_NONE:
+ break;
+ }
+ }
+ else if (nSId == SID_NAVIGATOR_OBJECT)
+ {
+ String aBookmarkStr;
+ aBookmarkStr += sal_Unicode( '#' );
+ const SfxItemSet* pArgs = rReq.GetArgs();
+ String aTarget = ((SfxStringItem&) pArgs->
+ Get(SID_NAVIGATOR_OBJECT)).GetValue();
+ aBookmarkStr += aTarget;
+ SfxStringItem aStrItem(SID_FILE_NAME, aBookmarkStr);
+ SfxStringItem aReferer(SID_REFERER, GetDocSh()->GetMedium()->GetName());
+ SfxViewFrame* pFrame = GetViewFrame();
+ SfxFrameItem aFrameItem(SID_DOCFRAME, pFrame);
+ SfxBoolItem aBrowseItem(SID_BROWSE, sal_True);
+ pFrame->GetDispatcher()->
+ Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aStrItem, &aFrameItem, &aBrowseItem, &aReferer, 0L);
+ }
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_NAVIGATOR_STATE );
+ rBindings.Invalidate( SID_NAVIGATOR_PAGENAME );
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* Statuswerte fuer Navigator zurueckgeben
+|*
+\************************************************************************/
+
+void DrawViewShell::GetNavigatorWinState( SfxItemSet& rSet )
+{
+ sal_uInt32 nState = NAVSTATE_NONE;
+ sal_uInt16 nCurrentPage = 0;
+ sal_uInt16 nFirstPage = 0;
+ sal_uInt16 nLastPage;
+ sal_Bool bEndless = sal_False;
+ String aPageName;
+
+ rtl::Reference< SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if( xSlideshow.is() && xSlideshow->isRunning() )
+ {
+ // pen activated?
+ nState |= xSlideshow->isDrawingPossible() ? NAVBTN_PEN_CHECKED : NAVBTN_PEN_UNCHECKED;
+
+ nCurrentPage = (sal_uInt16)xSlideshow->getCurrentPageNumber();
+ nFirstPage = (sal_uInt16)xSlideshow->getFirstPageNumber();
+ nLastPage = (sal_uInt16)xSlideshow->getLastPageNumber();
+ bEndless = xSlideshow->isEndless();
+
+ // Get the page for the current page number.
+ SdPage* pPage = 0;
+ if( nCurrentPage < GetDoc()->GetSdPageCount( PK_STANDARD ) )
+ pPage = GetDoc()->GetSdPage (nCurrentPage, PK_STANDARD);
+
+ if(pPage)
+ aPageName = pPage->GetName();
+ }
+ else
+ {
+ nState |= NAVBTN_PEN_DISABLED | NAVTLB_UPDATE;
+
+ if (mpActualPage != NULL)
+ {
+ nCurrentPage = ( mpActualPage->GetPageNum() - 1 ) / 2;
+ aPageName = mpActualPage->GetName();
+ }
+ nLastPage = GetDoc()->GetSdPageCount( mePageKind ) - 1;
+ }
+
+ // erste Seite / vorherige Seite
+ if( nCurrentPage == nFirstPage )
+ {
+ nState |= NAVBTN_FIRST_DISABLED;
+ if( !bEndless )
+ nState |= NAVBTN_PREV_DISABLED;
+ else
+ nState |= NAVBTN_PREV_ENABLED;
+ }
+ else
+ {
+ nState |= NAVBTN_FIRST_ENABLED | NAVBTN_PREV_ENABLED;
+ }
+
+ // letzte Seite / naechste Seite
+ if( nCurrentPage == nLastPage )
+ {
+ nState |= NAVBTN_LAST_DISABLED;
+ if( !bEndless )
+ nState |= NAVBTN_NEXT_DISABLED;
+ else
+ nState |= NAVBTN_NEXT_ENABLED;
+ }
+ else
+ {
+ nState |= NAVBTN_LAST_ENABLED | NAVBTN_NEXT_ENABLED;
+ }
+
+ rSet.Put( SfxUInt32Item( SID_NAVIGATOR_STATE, nState ) );
+ rSet.Put( SfxStringItem( SID_NAVIGATOR_PAGENAME, aPageName ) );
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
new file mode 100755
index 000000000000..a6f379b6fc38
--- /dev/null
+++ b/sd/source/ui/view/drviewse.cxx
@@ -0,0 +1,1694 @@
+/*************************************************************************
+ *
+ * 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 <com/sun/star/presentation/XPresentation2.hpp>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include "undo/undomanager.hxx"
+#include <vcl/waitobj.hxx>
+#include <svl/aeitem.hxx>
+#include <editeng/editstat.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/urlbmk.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/fmshell.hxx>
+#include <vcl/scrbar.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdorect.hxx>
+#include <svx/svdograf.hxx>
+#include <svl/eitem.hxx>
+#include <editeng/eeitem.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/request.hxx>
+#include <svx/svxids.hrc>
+#include <editeng/flditem.hxx>
+#include <svx/ruler.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <tools/urlobj.hxx>
+#include <svl/slstitm.hxx>
+#include <sfx2/ipclient.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <svl/urihelper.hxx>
+#include <sfx2/docfile.hxx>
+
+#include "DrawViewShell.hxx"
+#include "slideshow.hxx"
+#include "ViewShellImplementation.hxx"
+#include "ViewShellHint.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include "app.hrc"
+#include "glob.hrc"
+#include "strings.hrc"
+#include "res_bmp.hrc"
+#include "drawdoc.hxx"
+#include "fusel.hxx"
+#include "futext.hxx"
+#include "fuconrec.hxx"
+#include "fuconcs.hxx"
+#include "fuconuno.hxx"
+#include "fuconbez.hxx"
+#include "fuediglu.hxx"
+#include "fuconarc.hxx"
+#include "fucon3d.hxx"
+#include "sdresid.hxx"
+#include "slideshow.hxx"
+#include "Outliner.hxx"
+#include "PresentationViewShell.hxx"
+#include "sdpage.hxx"
+#include "FrameView.hxx"
+#include "zoomlist.hxx"
+#include "drawview.hxx"
+#include "DrawDocShell.hxx"
+#include "sdattr.hxx"
+#include "ViewShellBase.hxx"
+#include "ToolBarManager.hxx"
+#include "anminfo.hxx"
+#include "optsitem.hxx"
+#include "Window.hxx"
+#include "fuformatpaintbrush.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::presentation;
+
+namespace sd {
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+/*************************************************************************
+|*
+|* Permanente Funktionen
+|*
+\************************************************************************/
+
+void ImpAddPrintableCharactersToTextEdit(SfxRequest& rReq, ::sd::View* pView)
+{
+ // #98198# evtl. feed characters to activated textedit
+ const SfxItemSet* pSet = rReq.GetArgs();
+
+ if(pSet)
+ {
+ String aInputString;
+
+ if(SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_CHAR))
+ aInputString = ((SfxStringItem&)pSet->Get(SID_ATTR_CHAR)).GetValue();
+
+ if(aInputString.Len())
+ {
+ OutlinerView* pOLV = pView->GetTextEditOutlinerView();
+
+ if(pOLV)
+ {
+ for(sal_uInt16 a(0); a < aInputString.Len(); a++)
+ {
+ sal_Char aChar = (sal_Char)aInputString.GetChar(a);
+ KeyCode aKeyCode;
+ KeyEvent aKeyEvent(aChar, aKeyCode);
+
+ // add actual character
+ pOLV->PostKeyEvent(aKeyEvent);
+ }
+ }
+ }
+ }
+}
+
+void DrawViewShell::FuPermanent(SfxRequest& rReq)
+{
+ // Waehrend einer Native-Diashow wird nichts ausgefuehrt!
+
+ if (SlideShow::IsRunning(GetViewShellBase()))
+ return;
+
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ if( HasCurrentFunction() &&
+ ( nSId == SID_TEXTEDIT || nSId == SID_ATTR_CHAR || nSId == SID_TEXT_FITTOSIZE ||
+ nSId == SID_ATTR_CHAR_VERTICAL || nSId == SID_TEXT_FITTOSIZE_VERTICAL ) )
+ {
+ FunctionReference xFunc( GetCurrentFunction() );
+
+ FuText* pFuText = dynamic_cast< FuText* >( xFunc.get() );
+
+ if( pFuText )
+ {
+ pFuText->SetPermanent(sal_True);
+ xFunc->ReceiveRequest( rReq );
+
+ MapSlot( nSId );
+
+ Invalidate();
+
+ Invalidate();
+
+ // #98198# evtl. feed characters to activated textedit
+ if(SID_ATTR_CHAR == nSId && GetView() && GetView()->IsTextEdit())
+ ImpAddPrintableCharactersToTextEdit(rReq, GetView());
+
+ rReq.Done();
+ return;
+ }
+ }
+
+ CheckLineTo (rReq);
+ sal_uInt16 nOldSId = 0;
+ sal_Bool bPermanent = sal_False;
+
+ if( !mpDrawView )
+ return;
+
+ if(HasCurrentFunction())
+ {
+ if( (nSId == SID_FORMATPAINTBRUSH) && (GetCurrentFunction()->GetSlotID() == SID_TEXTEDIT) )
+ {
+ // save text edit mode for format paintbrush!
+ SetOldFunction( GetCurrentFunction() );
+ }
+ else
+ {
+ if(GetOldFunction() == GetCurrentFunction())
+ {
+ SetOldFunction(0);
+ }
+ }
+
+ if ( nSId != SID_TEXTEDIT && nSId != SID_ATTR_CHAR && nSId != SID_TEXT_FITTOSIZE &&
+ nSId != SID_ATTR_CHAR_VERTICAL && nSId != SID_TEXT_FITTOSIZE_VERTICAL &&
+ nSId != SID_FORMATPAINTBRUSH &&
+ mpDrawView->IsTextEdit() )
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ if( HasCurrentFunction() )
+ {
+ nOldSId = GetCurrentFunction()->GetSlotID();
+
+ if (nOldSId == nSId ||
+ ((nOldSId == SID_TEXTEDIT || nOldSId == SID_ATTR_CHAR || nOldSId == SID_TEXT_FITTOSIZE ||
+ nOldSId == SID_ATTR_CHAR_VERTICAL || nOldSId == SID_TEXT_FITTOSIZE_VERTICAL) &&
+ (nSId == SID_TEXTEDIT || nSId == SID_ATTR_CHAR || nSId == SID_TEXT_FITTOSIZE ||
+ nSId == SID_ATTR_CHAR_VERTICAL || nSId == SID_TEXT_FITTOSIZE_VERTICAL )))
+ {
+ bPermanent = sal_True;
+ }
+
+ GetCurrentFunction()->Deactivate();
+ }
+
+ SetCurrentFunction(0);
+
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate(nOldSId);
+ rBind.Update(nOldSId);
+ }
+
+ // Slot wird gemapped (ToolboxImages/-Slots)
+ MapSlot( nSId );
+
+ switch ( nSId )
+ {
+ case SID_TEXTEDIT: // BASIC ???
+ case SID_ATTR_CHAR:
+ case SID_ATTR_CHAR_VERTICAL:
+ case SID_TEXT_FITTOSIZE:
+ case SID_TEXT_FITTOSIZE_VERTICAL:
+ {
+ SetCurrentFunction( FuText::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+ GetCurrentFunction()->DoExecute(rReq);
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_ATTR_CHAR );
+ rBindings.Invalidate( SID_ATTR_CHAR_VERTICAL );
+ rBindings.Invalidate( SID_TEXT_FITTOSIZE );
+ rBindings.Invalidate( SID_TEXT_FITTOSIZE_VERTICAL );
+
+ // #98198# evtl. feed characters to activated textedit
+ if(SID_ATTR_CHAR == nSId && GetView() && GetView()->IsTextEdit())
+ ImpAddPrintableCharactersToTextEdit(rReq, GetView());
+
+ rReq.Done();
+ }
+ break;
+
+ case SID_FM_CREATE_CONTROL:
+ {
+ SetCurrentFunction( FuConstructUnoControl::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+ rReq.Done();
+ }
+ break;
+
+ // #98721#
+ case SID_FM_CREATE_FIELDCONTROL:
+ {
+ SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, sal_False );
+ DBG_ASSERT( pDescriptorItem, "DrawViewShell::FuPermanent(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
+
+ if(pDescriptorItem)
+ {
+ // get the form view
+ FmFormView* pFormView = PTR_CAST(FmFormView, mpDrawView);
+ SdrPageView* pPageView = pFormView ? pFormView->GetSdrPageView() : NULL;
+
+ if(pPageView)
+ {
+ ::svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
+ SdrObject* pNewDBField = pFormView->CreateFieldControl(aDescriptor);
+
+ if(pNewDBField)
+ {
+ Rectangle aVisArea = GetActiveWindow()->PixelToLogic(Rectangle(Point(0,0), GetActiveWindow()->GetOutputSizePixel()));
+ Point aObjPos(aVisArea.Center());
+ Size aObjSize(pNewDBField->GetLogicRect().GetSize());
+ aObjPos.X() -= aObjSize.Width() / 2;
+ aObjPos.Y() -= aObjSize.Height() / 2;
+ Rectangle aNewObjectRectangle(aObjPos, aObjSize);
+
+ pNewDBField->SetLogicRect(aNewObjectRectangle);
+
+ GetView()->InsertObjectAtView(pNewDBField, *pPageView);
+ }
+ }
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_OBJECT_SELECT:
+ case SID_OBJECT_ROTATE:
+ case SID_OBJECT_MIRROR:
+ case SID_OBJECT_CROP:
+ case SID_OBJECT_TRANSPARENCE:
+ case SID_OBJECT_GRADIENT:
+ case SID_OBJECT_SHEAR:
+ case SID_OBJECT_CROOK_ROTATE:
+ case SID_OBJECT_CROOK_SLANT:
+ case SID_OBJECT_CROOK_STRETCH:
+ case SID_CONVERT_TO_3D_LATHE:
+ {
+ short nSlotId = rReq.GetSlot();
+
+ if( nSlotId == SID_OBJECT_ROTATE )
+ {
+ // togle rotation
+ if( nOldSId == nSlotId )
+ {
+ nSlotId = SID_OBJECT_SELECT;
+ rReq.SetSlot( nSlotId );
+ }
+ }
+
+ if (nSlotId == SID_OBJECT_CROOK_ROTATE ||
+ nSlotId == SID_OBJECT_CROOK_SLANT ||
+ nSlotId == SID_OBJECT_CROOK_STRETCH)
+ {
+ if ( mpDrawView->GetMarkedObjectList().GetMarkCount() > 0 &&
+ !mpDrawView->IsCrookAllowed( mpDrawView->IsCrookNoContortion() ) )
+ {
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else if ( QueryBox(GetActiveWindow(), WB_YES_NO,
+ String(SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER) )
+ ).Execute() == RET_YES )
+ {
+ // Implizite Wandlung in Bezier
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->ConvertMarkedToPathObj(sal_False);
+ }
+ }
+ }
+ else if (nSlotId == SID_OBJECT_SHEAR)
+ {
+ sal_uLong i = 0;
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ sal_uLong nMarkCnt = rMarkList.GetMarkCount();
+ sal_Bool b3DObjMarked = sal_False;
+
+ while (i < nMarkCnt && !b3DObjMarked)
+ {
+ if (rMarkList.GetMark(i)->GetMarkedSdrObj()->ISA(E3dObject))
+ {
+ b3DObjMarked = sal_True;
+ }
+ else
+ {
+ i++;
+ }
+ }
+
+ if ( nMarkCnt > 0 && !b3DObjMarked &&
+ (!mpDrawView->IsShearAllowed() || !mpDrawView->IsDistortAllowed()) )
+ {
+ if ( mpDrawView->IsPresObjSelected() )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else if ( QueryBox(GetActiveWindow(), WB_YES_NO,
+ String(SdResId(STR_ASK_FOR_CONVERT_TO_BEZIER) )
+ ).Execute() == RET_YES )
+ {
+ // Implizite Wandlung in Bezier
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ mpDrawView->ConvertMarkedToPathObj(sal_False);
+ }
+ }
+ }
+
+ SetCurrentFunction( FuSelection::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq) );
+ rReq.Done();
+ Invalidate( SID_OBJECT_SELECT );
+ }
+ break;
+
+ case SID_DRAW_LINE:
+ case SID_DRAW_XLINE:
+ case SID_DRAW_MEASURELINE:
+ case SID_LINE_ARROW_START:
+ case SID_LINE_ARROW_END:
+ case SID_LINE_ARROWS:
+ case SID_LINE_ARROW_CIRCLE:
+ case SID_LINE_CIRCLE_ARROW:
+ case SID_LINE_ARROW_SQUARE:
+ case SID_LINE_SQUARE_ARROW:
+
+ case SID_DRAW_RECT:
+ case SID_DRAW_RECT_NOFILL:
+ case SID_DRAW_RECT_ROUND:
+ case SID_DRAW_RECT_ROUND_NOFILL:
+ case SID_DRAW_SQUARE:
+ case SID_DRAW_SQUARE_NOFILL:
+ case SID_DRAW_SQUARE_ROUND:
+ case SID_DRAW_SQUARE_ROUND_NOFILL:
+ case SID_DRAW_ELLIPSE:
+ case SID_DRAW_ELLIPSE_NOFILL:
+ case SID_DRAW_CIRCLE:
+ case SID_DRAW_CIRCLE_NOFILL:
+ case SID_DRAW_CAPTION:
+ case SID_DRAW_CAPTION_VERTICAL:
+ case SID_TOOL_CONNECTOR:
+ case SID_CONNECTOR_ARROW_START:
+ case SID_CONNECTOR_ARROW_END:
+ case SID_CONNECTOR_ARROWS:
+ case SID_CONNECTOR_CIRCLE_START:
+ case SID_CONNECTOR_CIRCLE_END:
+ case SID_CONNECTOR_CIRCLES:
+ case SID_CONNECTOR_LINE:
+ case SID_CONNECTOR_LINE_ARROW_START:
+ case SID_CONNECTOR_LINE_ARROW_END:
+ case SID_CONNECTOR_LINE_ARROWS:
+ case SID_CONNECTOR_LINE_CIRCLE_START:
+ case SID_CONNECTOR_LINE_CIRCLE_END:
+ case SID_CONNECTOR_LINE_CIRCLES:
+ case SID_CONNECTOR_CURVE:
+ case SID_CONNECTOR_CURVE_ARROW_START:
+ case SID_CONNECTOR_CURVE_ARROW_END:
+ case SID_CONNECTOR_CURVE_ARROWS:
+ case SID_CONNECTOR_CURVE_CIRCLE_START:
+ case SID_CONNECTOR_CURVE_CIRCLE_END:
+ case SID_CONNECTOR_CURVE_CIRCLES:
+ case SID_CONNECTOR_LINES:
+ case SID_CONNECTOR_LINES_ARROW_START:
+ case SID_CONNECTOR_LINES_ARROW_END:
+ case SID_CONNECTOR_LINES_ARROWS:
+ case SID_CONNECTOR_LINES_CIRCLE_START:
+ case SID_CONNECTOR_LINES_CIRCLE_END:
+ case SID_CONNECTOR_LINES_CIRCLES:
+ {
+ SetCurrentFunction( FuConstructRectangle::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+ rReq.Done();
+ }
+ break;
+ case SID_DRAW_POLYGON:
+ case SID_DRAW_POLYGON_NOFILL:
+ case SID_DRAW_XPOLYGON:
+ case SID_DRAW_XPOLYGON_NOFILL:
+ case SID_DRAW_FREELINE:
+ case SID_DRAW_FREELINE_NOFILL:
+ case SID_DRAW_BEZIER_FILL: // BASIC
+ case SID_DRAW_BEZIER_NOFILL: // BASIC
+ {
+ SetCurrentFunction( FuConstructBezierPolygon::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent) );
+ rReq.Done();
+ }
+ break;
+
+ case SID_GLUE_EDITMODE:
+ {
+ if (nOldSId != SID_GLUE_EDITMODE)
+ {
+ SetCurrentFunction( FuEditGluePoints::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+ }
+ else
+ {
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+ }
+
+ rReq.Done();
+ }
+ break;
+
+ case SID_DRAW_ARC:
+ case SID_DRAW_CIRCLEARC:
+ case SID_DRAW_PIE:
+ case SID_DRAW_PIE_NOFILL:
+ case SID_DRAW_CIRCLEPIE:
+ case SID_DRAW_CIRCLEPIE_NOFILL:
+ case SID_DRAW_ELLIPSECUT:
+ case SID_DRAW_ELLIPSECUT_NOFILL:
+ case SID_DRAW_CIRCLECUT:
+ case SID_DRAW_CIRCLECUT_NOFILL:
+ {
+ SetCurrentFunction( FuConstructArc::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent) );
+ rReq.Done();
+ }
+ break;
+
+ case SID_3D_CUBE:
+ case SID_3D_SHELL:
+ case SID_3D_SPHERE:
+ case SID_3D_TORUS:
+ case SID_3D_HALF_SPHERE:
+ case SID_3D_CYLINDER:
+ case SID_3D_CONE:
+ case SID_3D_PYRAMID:
+ {
+ SetCurrentFunction( FuConstruct3dObject::Create(this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+ rReq.Done();
+ }
+ break;
+
+ case SID_DRAWTBX_CS_BASIC :
+ case SID_DRAWTBX_CS_SYMBOL :
+ case SID_DRAWTBX_CS_ARROW :
+ case SID_DRAWTBX_CS_FLOWCHART :
+ case SID_DRAWTBX_CS_CALLOUT :
+ case SID_DRAWTBX_CS_STAR :
+ case SID_DRAW_CS_ID :
+ {
+ SetCurrentFunction( FuConstructCustomShape::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq, bPermanent ) );
+ rReq.Done();
+
+ if ( nSId != SID_DRAW_CS_ID )
+ {
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( nSId );
+ rBind.Update( nSId );
+ }
+ }
+ break;
+
+ case SID_FORMATPAINTBRUSH:
+ {
+ SetCurrentFunction( FuFormatPaintBrush::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ rReq.Done();
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( nSId );
+ rBind.Update( nSId );
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ if(HasOldFunction())
+ {
+ sal_uInt16 nSlotId = GetOldFunction()->GetSlotID();
+
+ GetOldFunction()->Deactivate();
+ SetOldFunction(0);
+
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( nSlotId );
+ rBind.Update( nSlotId );
+ }
+
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->Activate();
+ SetOldFunction( GetCurrentFunction() );
+
+ SetHelpId( GetCurrentFunction()->GetSlotID() );
+ }
+
+ // Shell wird invalidiert, schneller als einzeln (laut MI)
+ // Jetzt explizit der letzte Slot incl. Update()
+ Invalidate();
+
+ // #97016# III CTRL-SID_OBJECT_SELECT -> select first draw object if none is selected yet
+ if(SID_OBJECT_SELECT == nSId && HasCurrentFunction() && (rReq.GetModifier() & KEY_MOD1))
+ {
+ if(!GetView()->AreObjectsMarked())
+ {
+ // select first object
+ GetView()->UnmarkAllObj();
+ GetView()->MarkNextObj(sal_True);
+
+ // ...and make it visible
+ if(GetView()->AreObjectsMarked())
+ GetView()->MakeVisible(GetView()->GetAllMarkedRect(), *GetActiveWindow());
+ }
+ }
+
+ // #97016# with qualifier construct directly
+ if(HasCurrentFunction() && (rReq.GetModifier() & KEY_MOD1))
+ {
+ // get SdOptions
+ SdOptions* pOptions = SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
+ sal_uInt32 nDefaultObjectSizeWidth(pOptions->GetDefaultObjectSizeWidth());
+ sal_uInt32 nDefaultObjectSizeHeight(pOptions->GetDefaultObjectSizeHeight());
+
+ // calc position and size
+ Rectangle aVisArea = GetActiveWindow()->PixelToLogic(Rectangle(Point(0,0), GetActiveWindow()->GetOutputSizePixel()));
+ Point aPagePos = aVisArea.Center();
+ aPagePos.X() -= nDefaultObjectSizeWidth / 2;
+ aPagePos.Y() -= nDefaultObjectSizeHeight / 2;
+ Rectangle aNewObjectRectangle(aPagePos, Size(nDefaultObjectSizeWidth, nDefaultObjectSizeHeight));
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ // create the default object
+ SdrObject* pObj = GetCurrentFunction()->CreateDefaultObject(nSId, aNewObjectRectangle);
+
+ if(pObj)
+ {
+ // insert into page
+ GetView()->InsertObjectAtView(pObj, *pPageView);
+
+ // Now that pFuActual has done what it was created for we
+ // can switch on the edit mode for callout objects.
+ switch (nSId)
+ {
+ case SID_DRAW_CAPTION:
+ case SID_DRAW_CAPTION_VERTICAL:
+ {
+ // Make FuText the current function.
+ SfxUInt16Item aItem (SID_TEXTEDIT, 1);
+ GetViewFrame()->GetDispatcher()->
+ Execute(SID_TEXTEDIT, SFX_CALLMODE_SYNCHRON |
+ SFX_CALLMODE_RECORD, &aItem, 0L);
+ // Put text object into edit mode.
+ GetView()->SdrBeginTextEdit(static_cast<SdrTextObj*>(pObj), pPageView);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// service routine for Undo/Redo implementation
+extern SfxUndoManager* ImpGetUndoManagerFromViewShell(DrawViewShell& rDViewShell);
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Support-Funktionen
+|*
+\************************************************************************/
+
+void DrawViewShell::FuSupport(SfxRequest& rReq)
+{
+ if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
+ GetDocSh()->SetStyleFamily(((SfxUInt16Item&)rReq.GetArgs()->Get( SID_STYLE_FAMILY )).GetValue());
+
+ // Waehrend einer Native-Diashow wird nichts ausgefuehrt!
+ if(SlideShow::IsRunning(GetViewShellBase()) &&
+ (rReq.GetSlot() != SID_PRESENTATION_END &&
+ rReq.GetSlot() != SID_SIZE_PAGE))
+ return;
+
+ CheckLineTo (rReq);
+
+ if( !mpDrawView )
+ return;
+
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ // Slot wird evtl. gemapped (ToolboxImages/-Slots)
+ MapSlot( nSId );
+
+ switch ( nSId )
+ {
+ case SID_CLEAR_UNDO_STACK:
+ {
+ GetDocSh()->ClearUndoBuffer();
+ rReq.Ignore ();
+ }
+ break;
+
+ // Slots der ToolboxController gemapped ausfuehren
+ case SID_OBJECT_CHOOSE_MODE:
+ case SID_POSITION:
+ case SID_OBJECT_ALIGN:
+ case SID_ZOOM_TOOLBOX:
+ case SID_DRAWTBX_TEXT:
+ case SID_DRAWTBX_RECTANGLES:
+ case SID_DRAWTBX_ELLIPSES:
+ case SID_DRAWTBX_LINES:
+ case SID_DRAWTBX_ARROWS:
+ case SID_DRAWTBX_3D_OBJECTS:
+ case SID_DRAWTBX_CONNECTORS:
+ case SID_DRAWTBX_INSERT:
+ {
+ sal_uInt16 nMappedSlot = GetMappedSlot( nSId );
+ if( nMappedSlot > 0 )
+ {
+ SfxRequest aReq( nMappedSlot, 0, GetDoc()->GetItemPool() );
+ ExecuteSlot( aReq );
+ }
+ }
+ break;
+
+ case SID_PRESENTATION:
+ case SID_REHEARSE_TIMINGS:
+ {
+ Reference< XPresentation2 > xPresentation( GetDoc()->getPresentation() );
+ if( xPresentation.is() )
+ {
+ if( ( SID_REHEARSE_TIMINGS != rReq.GetSlot() ) )
+ xPresentation->start();
+ else
+ xPresentation->rehearseTimings();
+ }
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_PRESENTATION_END:
+ {
+ StopSlideShow(true);
+
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_BEZIER_EDIT:
+ {
+ mpDrawView->SetFrameDragSingles(!mpDrawView->IsFrameDragSingles());
+
+ /******************************************************************
+ * ObjectBar einschalten
+ ******************************************************************/
+ if( dynamic_cast< FuSelection* >( GetCurrentFunction().get() ) || dynamic_cast< FuConstructBezierPolygon* >( GetCurrentFunction().get() ) )
+ {
+ // Tell the tool bar manager about the context change.
+ GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView);
+ }
+
+ Invalidate(SID_BEZIER_EDIT);
+ rReq.Ignore();
+ }
+ break;
+
+ case SID_OBJECT_CLOSE:
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ if ( rMarkList.GetMark(0) && !mpDrawView->IsAction() )
+ {
+ SdrPathObj* pPathObj = (SdrPathObj*) rMarkList.GetMark(0)->GetMarkedSdrObj();
+ const bool bUndo = mpDrawView->IsUndoEnabled();
+ if( bUndo )
+ mpDrawView->BegUndo(String(SdResId(STR_UNDO_BEZCLOSE)));
+
+ mpDrawView->UnmarkAllPoints();
+
+ if( bUndo )
+ mpDrawView->AddUndo(new SdrUndoGeoObj(*pPathObj));
+
+ pPathObj->ToggleClosed();
+
+ if( bUndo )
+ mpDrawView->EndUndo();
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_CUT:
+ {
+ if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->DoCut();
+ }
+ else if(mpDrawView)
+ {
+ mpDrawView->DoCut();
+ }
+ }
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_COPY:
+ {
+ if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->DoCopy();
+ }
+ else if( mpDrawView )
+ {
+ mpDrawView->DoCopy();
+ }
+ }
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_PASTE:
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->DoPaste();
+ }
+ else if(mpDrawView)
+ {
+ mpDrawView->DoPaste();
+ }
+
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_CLIPBOARD_FORMAT_ITEMS:
+ {
+ WaitObject aWait( (Window*)GetActiveWindow() );
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+ sal_uInt32 nFormat = 0;
+
+ if( pReqArgs )
+ {
+ SFX_REQUEST_ARG( rReq, pIsActive, SfxUInt32Item, SID_CLIPBOARD_FORMAT_ITEMS, sal_False );
+ nFormat = pIsActive->GetValue();
+ }
+
+
+ if( nFormat && aDataHelper.GetTransferable().is() )
+ {
+ sal_Int8 nAction = DND_ACTION_COPY;
+
+ if( !mpDrawView->InsertData( aDataHelper,
+ GetActiveWindow()->PixelToLogic( Rectangle( Point(), GetActiveWindow()->GetOutputSizePixel() ).Center() ),
+ nAction, sal_False, nFormat ) )
+ {
+ INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
+
+ if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
+ ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
+ ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
+ {
+ InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
+ }
+ }
+ }
+ }
+ break;
+
+ case SID_DELETE:
+ {
+ if ( mpDrawView->IsTextEdit() )
+ {
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+
+ if (pOLV)
+ {
+ KeyCode aKCode(KEY_DELETE);
+ KeyEvent aKEvt( 0, aKCode);
+ pOLV->PostKeyEvent(aKEvt);
+ }
+ }
+ else if ( mpDrawView->IsPresObjSelected(sal_False, sal_True, sal_False, sal_True) )
+ {
+ ::sd::Window* pWindow = GetActiveWindow();
+ InfoBox(pWindow, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ }
+ else
+ {
+ KeyCode aKCode(KEY_DELETE);
+ KeyEvent aKEvt( 0, aKCode);
+
+ bool bConsumed = mpDrawView && mpDrawView->getSmartTags().KeyInput( aKEvt );
+
+ if( !bConsumed && HasCurrentFunction() )
+ bConsumed = GetCurrentFunction()->KeyInput(aKEvt);
+
+ if( !bConsumed && mpDrawView )
+ mpDrawView->DeleteMarked();
+ }
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_NOTESMODE:
+ case SID_HANDOUTMODE:
+ // AutoLayouts have to be ready.
+ GetDoc()->StopWorkStartupDelay();
+ // Fall through to following case statements.
+
+ case SID_DRAWINGMODE:
+ case SID_DIAMODE:
+ case SID_OUTLINEMODE:
+ // Let the sub-shell manager handle the slot handling.
+ framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
+ nSId,
+ rReq);
+ rReq.Ignore ();
+ break;
+
+ case SID_MASTERPAGE: // BASIC
+ case SID_SLIDE_MASTERPAGE: // BASIC
+ case SID_TITLE_MASTERPAGE: // BASIC
+ case SID_NOTES_MASTERPAGE: // BASIC
+ case SID_HANDOUT_MASTERPAGE: // BASIC
+ {
+ // AutoLayouts muessen fertig sein
+ GetDoc()->StopWorkStartupDelay();
+
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ if ( pReqArgs )
+ {
+ SFX_REQUEST_ARG (rReq, pIsActive, SfxBoolItem, SID_MASTERPAGE, sal_False);
+ mbIsLayerModeActive = pIsActive->GetValue ();
+ }
+
+ Broadcast (
+ ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START));
+
+ if (nSId == SID_MASTERPAGE ||
+ (nSId == SID_SLIDE_MASTERPAGE && mePageKind == PK_STANDARD) ||
+ (nSId == SID_TITLE_MASTERPAGE && mePageKind == PK_STANDARD) ||
+ (nSId == SID_NOTES_MASTERPAGE && mePageKind == PK_NOTES) ||
+ (nSId == SID_HANDOUT_MASTERPAGE && mePageKind == PK_HANDOUT))
+ {
+ if (nSId == SID_TITLE_MASTERPAGE ||
+ nSId == SID_SLIDE_MASTERPAGE)
+ {
+ // Gibt es eine Seite mit dem AutoLayout "Titel"?
+ sal_Bool bFound = sal_False;
+ sal_uInt16 i = 0;
+ sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
+
+ while (i < nCount && !bFound)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
+
+ if (nSId == SID_TITLE_MASTERPAGE && pPage->GetAutoLayout() == AUTOLAYOUT_TITLE)
+ {
+ bFound = sal_True;
+ SwitchPage((pPage->GetPageNum() - 1) / 2);
+ }
+ else if (nSId == SID_SLIDE_MASTERPAGE && pPage->GetAutoLayout() != AUTOLAYOUT_TITLE)
+ {
+ bFound = sal_True;
+ SwitchPage((pPage->GetPageNum() - 1) / 2);
+ }
+
+ i++;
+ }
+ }
+
+ // Default-Layer der MasterPage einschalten
+ mpDrawView->SetActiveLayer( String( SdResId(STR_LAYER_BCKGRNDOBJ) ) );
+
+ ChangeEditMode(EM_MASTERPAGE, mbIsLayerModeActive);
+
+ if(HasCurrentFunction(SID_BEZIER_EDIT))
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+ }
+ else
+ {
+ // Switch to requested ViewShell.
+ ::OUString sRequestedView;
+ PageKind ePageKind;
+ switch (nSId)
+ {
+ case SID_SLIDE_MASTERPAGE:
+ case SID_TITLE_MASTERPAGE:
+ default:
+ sRequestedView = framework::FrameworkHelper::msImpressViewURL;
+ ePageKind = PK_STANDARD;
+ break;
+
+ case SID_NOTES_MASTERPAGE:
+ sRequestedView = framework::FrameworkHelper::msNotesViewURL;
+ ePageKind = PK_NOTES;
+ break;
+
+ case SID_HANDOUT_MASTERPAGE:
+ sRequestedView = framework::FrameworkHelper::msHandoutViewURL;
+ ePageKind = PK_HANDOUT;
+ break;
+ }
+
+ mpFrameView->SetViewShEditMode(EM_MASTERPAGE, ePageKind);
+ mpFrameView->SetLayerMode(mbIsLayerModeActive);
+ framework::FrameworkHelper::Instance(GetViewShellBase())->RequestView(
+ sRequestedView,
+ framework::FrameworkHelper::msCenterPaneURL);
+ }
+ Broadcast (
+ ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END));
+
+ InvalidateWindows();
+ Invalidate();
+
+ rReq.Done();
+ }
+ break;
+
+
+ case SID_CLOSE_MASTER_VIEW:
+ {
+ Broadcast (
+ ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_START));
+
+ // Switch page back to the first one. Not doing so leads to a
+ // crash. This seems to be some bug in the edit mode switching
+ // and page switching methods.
+ SwitchPage (0);
+ ChangeEditMode(EM_PAGE, IsLayerModeActive());
+ Broadcast (
+ ViewShellHint(ViewShellHint::HINT_CHANGE_EDIT_MODE_END));
+
+ if(HasCurrentFunction(SID_BEZIER_EDIT))
+ {
+ GetViewFrame()->GetDispatcher()->Execute(
+ SID_OBJECT_SELECT,
+ SFX_CALLMODE_ASYNCHRON);
+ }
+
+
+ rReq.Done();
+ }
+ break;
+
+
+ case SID_RULER:
+ {
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ // #97516# Remember old ruler state
+ sal_Bool bOldHasRuler(HasRuler());
+
+ if ( pReqArgs )
+ {
+ SFX_REQUEST_ARG (rReq, pIsActive, SfxBoolItem, SID_RULER, sal_False);
+ SetRuler (pIsActive->GetValue ());
+ }
+ else SetRuler (!HasRuler());
+
+ // #97516# Did ruler state change? Tell that to SdOptions, too.
+ sal_Bool bHasRuler(HasRuler());
+
+ if(bOldHasRuler != bHasRuler)
+ {
+ SdOptions* pOptions = SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
+
+ if(pOptions && pOptions->IsRulerVisible() != bHasRuler)
+ {
+ pOptions->SetRulerVisible(bHasRuler);
+ }
+ }
+
+ Invalidate (SID_RULER);
+ Resize();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_SIZE_PAGE:
+ case SID_SIZE_PAGE_WIDTH: // BASIC
+ {
+ mbZoomOnPage = ( rReq.GetSlot() == SID_SIZE_PAGE );
+
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+
+ if ( pPageView )
+ {
+ Point aPagePos(0, 0); // = pPageView->GetOffset();
+ Size aPageSize = pPageView->GetPage()->GetSize();
+
+ aPagePos.X() += aPageSize.Width() / 2;
+ aPageSize.Width() = (long) (aPageSize.Width() * 1.03);
+
+ if( rReq.GetSlot() == SID_SIZE_PAGE )
+ {
+ aPagePos.Y() += aPageSize.Height() / 2;
+ aPageSize.Height() = (long) (aPageSize.Height() * 1.03);
+ aPagePos.Y() -= aPageSize.Height() / 2;
+ }
+ else
+ {
+ Point aPt = GetActiveWindow()->PixelToLogic( Point( 0, GetActiveWindow()->GetSizePixel().Height() / 2 ) );
+ aPagePos.Y() += aPt.Y();
+ aPageSize.Height() = 2;
+ }
+
+ aPagePos.X() -= aPageSize.Width() / 2;
+
+ SetZoomRect( Rectangle( aPagePos, aPageSize ) );
+
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
+ GetActiveWindow()->GetOutputSizePixel()) );
+ mpZoomList->InsertZoomRect(aVisAreaWin);
+ }
+ Invalidate( SID_ZOOM_IN );
+ Invalidate( SID_ZOOM_OUT );
+ Invalidate( SID_ZOOM_PANNING );
+ Invalidate( SID_ZOOM_TOOLBOX );
+ rReq.Done ();
+ }
+ break;
+
+ case SID_SIZE_REAL: // BASIC
+ {
+ mbZoomOnPage = sal_False;
+ SetZoom( 100 );
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
+ GetActiveWindow()->GetOutputSizePixel()) );
+ mpZoomList->InsertZoomRect(aVisAreaWin);
+ Invalidate( SID_ZOOM_IN );
+ Invalidate( SID_ZOOM_OUT );
+ Invalidate( SID_ZOOM_PANNING );
+ Invalidate( SID_ZOOM_TOOLBOX );
+ rReq.Done ();
+ }
+ break;
+
+ case SID_ZOOM_IN: // BASIC
+ {
+ mbZoomOnPage = sal_False;
+ SetZoom( Max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
+ GetActiveWindow()->GetOutputSizePixel()) );
+ mpZoomList->InsertZoomRect(aVisAreaWin);
+ Invalidate( SID_ZOOM_IN );
+ Invalidate( SID_ZOOM_OUT );
+ Invalidate( SID_ZOOM_PANNING );
+ Invalidate( SID_ZOOM_TOOLBOX );
+ rReq.Done ();
+ }
+ break;
+
+ case SID_SIZE_VISAREA:
+ {
+ Rectangle aVisArea = mpFrameView->GetVisArea();
+ Size aVisAreaSize = aVisArea.GetSize();
+
+ if (aVisAreaSize.Height()!=0 && aVisAreaSize.Width()!=0)
+ {
+ mbZoomOnPage = sal_False;
+ SetZoomRect(aVisArea);
+ Invalidate( SID_ZOOM_IN );
+ Invalidate( SID_ZOOM_OUT );
+ Invalidate( SID_ZOOM_PANNING );
+ Invalidate( SID_ZOOM_TOOLBOX );
+ }
+ rReq.Done ();
+ }
+ break;
+
+ // Namensverwirrung: SID_SIZE_OPTIMAL -> Zoom auf selektierte Objekte
+ // --> Wird als Objektzoom im Programm angeboten
+ case SID_SIZE_OPTIMAL: // BASIC
+ {
+ mbZoomOnPage = sal_False;
+ if ( mpDrawView->AreObjectsMarked() )
+ {
+ maMarkRect = mpDrawView->GetAllMarkedRect();
+ long nW = (long) (maMarkRect.GetWidth() * 1.03);
+ long nH = (long) (maMarkRect.GetHeight() * 1.03);
+ Point aPos = maMarkRect.Center();
+ aPos.X() -= nW / 2;
+ aPos.Y() -= nH / 2;
+ if ( nW && nH )
+ {
+ SetZoomRect(Rectangle(aPos, Size(nW, nH)));
+
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
+ GetActiveWindow()->GetOutputSizePixel()) );
+ mpZoomList->InsertZoomRect(aVisAreaWin);
+ }
+ }
+ Invalidate( SID_ZOOM_IN );
+ Invalidate( SID_ZOOM_OUT );
+ Invalidate( SID_ZOOM_PANNING );
+ Invalidate( SID_ZOOM_TOOLBOX );
+ rReq.Done ();
+ }
+ break;
+
+ // Namensverwirrung: SID_SIZE_ALL -> Zoom auf alle Objekte
+ // --> Wird als Optimal im Programm angeboten
+ case SID_SIZE_ALL: // BASIC
+ {
+ mbZoomOnPage = sal_False;
+ SdrPageView* pPageView = mpDrawView->GetSdrPageView();
+
+ if( pPageView )
+ {
+ Rectangle aBoundRect( pPageView->GetObjList()->GetAllObjBoundRect() );
+
+ long nW = (long) (aBoundRect.GetWidth() * 1.03);
+ long nH = (long) (aBoundRect.GetHeight() * 1.03);
+ Point aPos = aBoundRect.Center();
+ aPos.X() -= nW / 2;
+ aPos.Y() -= nH / 2;
+ if ( nW && nH )
+ {
+ SetZoomRect( Rectangle( aPos, Size( nW, nH ) ) );
+
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
+ GetActiveWindow()->GetOutputSizePixel()) );
+ mpZoomList->InsertZoomRect(aVisAreaWin);
+ }
+
+ Invalidate( SID_ZOOM_IN );
+ Invalidate( SID_ZOOM_OUT );
+ Invalidate( SID_ZOOM_PANNING );
+ Invalidate( SID_ZOOM_TOOLBOX );
+ }
+ rReq.Done ();
+ }
+ break;
+
+ case SID_ZOOM_PREV:
+ {
+ if (mpDrawView->IsTextEdit())
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ if (mpZoomList->IsPreviousPossible())
+ {
+ // Vorheriges ZoomRect einstellen
+ SetZoomRect(mpZoomList->GetPreviousZoomRect());
+ }
+ rReq.Done ();
+ Invalidate( SID_ZOOM_TOOLBOX );
+ }
+ break;
+
+ case SID_ZOOM_NEXT:
+ {
+ if (mpDrawView->IsTextEdit())
+ {
+ mpDrawView->SdrEndTextEdit();
+ }
+
+ if (mpZoomList->IsNextPossible())
+ {
+ // Naechstes ZoomRect einstellen
+ SetZoomRect(mpZoomList->GetNextZoomRect());
+ }
+ rReq.Done ();
+ Invalidate( SID_ZOOM_TOOLBOX );
+ }
+ break;
+
+ case SID_GLUE_INSERT_POINT:
+ case SID_GLUE_PERCENT:
+ case SID_GLUE_ESCDIR:
+ case SID_GLUE_ESCDIR_LEFT:
+ case SID_GLUE_ESCDIR_RIGHT:
+ case SID_GLUE_ESCDIR_TOP:
+ case SID_GLUE_ESCDIR_BOTTOM:
+ case SID_GLUE_HORZALIGN_CENTER:
+ case SID_GLUE_HORZALIGN_LEFT:
+ case SID_GLUE_HORZALIGN_RIGHT:
+ case SID_GLUE_VERTALIGN_CENTER:
+ case SID_GLUE_VERTALIGN_TOP:
+ case SID_GLUE_VERTALIGN_BOTTOM:
+ {
+ FunctionReference xFunc( GetCurrentFunction() );
+ FuEditGluePoints* pFunc = dynamic_cast< FuEditGluePoints* >( xFunc.get() );
+
+ if(pFunc)
+ pFunc->ReceiveRequest(rReq);
+
+ rReq.Done();
+ }
+ break;
+
+#ifdef DBG_UTIL
+ case SID_SHOW_ITEMBROWSER:
+ {
+ mpDrawView->ShowItemBrowser( !mpDrawView->IsItemBrowserVisible() );
+ rReq.Done ();
+ }
+ break;
+#endif
+
+ case SID_AUTOSPELL_CHECK:
+ {
+ sal_Bool bOnlineSpell = !GetDoc()->GetOnlineSpell();
+ GetDoc()->SetOnlineSpell(bOnlineSpell);
+
+ ::Outliner* pOL = mpDrawView->GetTextEditOutliner();
+
+ if (pOL)
+ {
+ sal_uLong nCntrl = pOL->GetControlWord();
+
+ if (bOnlineSpell)
+ nCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ nCntrl &= ~EE_CNTRL_ONLINESPELLING;
+
+ pOL->SetControlWord(nCntrl);
+ }
+
+ GetActiveWindow()->Invalidate();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_CONVERT_TO_1BIT_THRESHOLD:
+ case SID_CONVERT_TO_1BIT_MATRIX:
+ case SID_CONVERT_TO_4BIT_GRAYS:
+ case SID_CONVERT_TO_4BIT_COLORS:
+ case SID_CONVERT_TO_8BIT_GRAYS:
+ case SID_CONVERT_TO_8BIT_COLORS:
+ case SID_CONVERT_TO_24BIT:
+ {
+ BmpConversion eBmpConvert = BMP_CONVERSION_NONE;
+
+ switch( nSId )
+ {
+ case SID_CONVERT_TO_1BIT_THRESHOLD:
+ eBmpConvert = BMP_CONVERSION_1BIT_THRESHOLD;
+ break;
+
+ case SID_CONVERT_TO_1BIT_MATRIX:
+ eBmpConvert = BMP_CONVERSION_1BIT_MATRIX;
+ break;
+
+ case SID_CONVERT_TO_4BIT_GRAYS:
+ eBmpConvert = BMP_CONVERSION_4BIT_GREYS;
+ break;
+
+ case SID_CONVERT_TO_4BIT_COLORS:
+ eBmpConvert = BMP_CONVERSION_4BIT_COLORS;
+ break;
+
+ case SID_CONVERT_TO_8BIT_GRAYS:
+ eBmpConvert = BMP_CONVERSION_8BIT_GREYS;
+ break;
+
+ case SID_CONVERT_TO_8BIT_COLORS:
+ eBmpConvert = BMP_CONVERSION_8BIT_COLORS;
+ break;
+
+ case SID_CONVERT_TO_24BIT:
+ eBmpConvert = BMP_CONVERSION_24BIT;
+ break;
+ }
+
+ mpDrawView->BegUndo(String(SdResId(STR_UNDO_COLORRESOLUTION)));
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+
+ for (sal_uLong i=0; i<rMarkList.GetMarkCount(); i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+
+ if (pObj->GetObjInventor() == SdrInventor)
+ {
+ if (pObj->GetObjIdentifier() == OBJ_GRAF && !((SdrGrafObj*) pObj)->IsLinkedGraphic())
+ {
+ const Graphic& rGraphic = ((SdrGrafObj*) pObj)->GetGraphic();
+
+ if( rGraphic.GetType() == GRAPHIC_BITMAP )
+ {
+ SdrGrafObj* pNewObj = (SdrGrafObj*) pObj->Clone();
+
+ if( rGraphic.IsAnimated() )
+ {
+ Animation aAnim( rGraphic.GetAnimation() );
+ aAnim.Convert( eBmpConvert );
+ pNewObj->SetGraphic( aAnim );
+ }
+ else
+ {
+ BitmapEx aBmpEx( rGraphic.GetBitmapEx() );
+ aBmpEx.Convert( eBmpConvert );
+ pNewObj->SetGraphic( aBmpEx );
+ }
+
+ mpDrawView->ReplaceObjectAtView( pObj, *mpDrawView->GetSdrPageView(), pNewObj );
+ }
+ }
+ }
+ }
+
+ mpDrawView->EndUndo();
+ rReq.Done ();
+ }
+ break;
+
+ case SID_TRANSLITERATE_SENTENCE_CASE:
+ case SID_TRANSLITERATE_TITLE_CASE:
+ case SID_TRANSLITERATE_TOGGLE_CASE:
+ case SID_TRANSLITERATE_UPPER:
+ case SID_TRANSLITERATE_LOWER:
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ {
+ OutlinerView* pOLV = GetView()->GetTextEditOutlinerView();
+ if( pOLV )
+ {
+ using namespace ::com::sun::star::i18n;
+ sal_Int32 nType = 0;
+
+ switch( nSId )
+ {
+ case SID_TRANSLITERATE_SENTENCE_CASE:
+ nType = TransliterationModulesExtra::SENTENCE_CASE;
+ break;
+ case SID_TRANSLITERATE_TITLE_CASE:
+ nType = TransliterationModulesExtra::TITLE_CASE;
+ break;
+ case SID_TRANSLITERATE_TOGGLE_CASE:
+ nType = TransliterationModulesExtra::TOGGLE_CASE;
+ break;
+ case SID_TRANSLITERATE_UPPER:
+ nType = TransliterationModules_LOWERCASE_UPPERCASE;
+ break;
+ case SID_TRANSLITERATE_LOWER:
+ nType = TransliterationModules_UPPERCASE_LOWERCASE;
+ break;
+ case SID_TRANSLITERATE_HALFWIDTH:
+ nType = TransliterationModules_FULLWIDTH_HALFWIDTH;
+ break;
+ case SID_TRANSLITERATE_FULLWIDTH:
+ nType = TransliterationModules_HALFWIDTH_FULLWIDTH;
+ break;
+ case SID_TRANSLITERATE_HIRAGANA:
+ nType = TransliterationModules_KATAKANA_HIRAGANA;
+ break;
+ case SID_TRANSLITERATE_KATAGANA:
+ nType = TransliterationModules_HIRAGANA_KATAKANA;
+ break;
+ }
+
+ pOLV->TransliterateText( nType );
+ }
+
+ rReq.Done();
+ }
+ break;
+
+ // #UndoRedo#
+ case SID_UNDO :
+ {
+ // #96090# moved implementation to BaseClass
+ ImpSidUndo(sal_True, rReq);
+ }
+ break;
+ case SID_REDO :
+ {
+ // #96090# moved implementation to BaseClass
+ ImpSidRedo(sal_True, rReq);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+/*************************************************************************
+|*
+|* URL-Feld einfuegen
+|*
+\************************************************************************/
+
+void DrawViewShell::InsertURLField(const String& rURL, const String& rText,
+ const String& rTarget, const Point* pPos)
+{
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+
+ if (pOLV)
+ {
+ ESelection aSel( pOLV->GetSelection() );
+ SvxFieldItem aURLItem( SvxURLField( rURL, rText, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD );
+ pOLV->InsertField( aURLItem );
+ if ( aSel.nStartPos <= aSel.nEndPos )
+ aSel.nEndPos = aSel.nStartPos + 1;
+ else
+ aSel.nStartPos = aSel.nEndPos + 1;
+ pOLV->SetSelection( aSel );
+ }
+ else
+ {
+ Outliner* pOutl = GetDoc()->GetInternalOutliner();
+ pOutl->Init( OUTLINERMODE_TEXTOBJECT );
+ sal_uInt16 nOutlMode = pOutl->GetMode();
+
+ SvxURLField aURLField(rURL, rText, SVXURLFORMAT_REPR);
+ aURLField.SetTargetFrame(rTarget);
+ SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD);
+ pOutl->QuickInsertField( aURLItem, ESelection() );
+ OutlinerParaObject* pOutlParaObject = pOutl->CreateParaObject();
+
+ SdrRectObj* pRectObj = new SdrRectObj(OBJ_TEXT);
+
+ pOutl->UpdateFields();
+ pOutl->SetUpdateMode( sal_True );
+ Size aSize(pOutl->CalcTextSize());
+ pOutl->SetUpdateMode( sal_False );
+
+ Point aPos;
+
+ if (pPos)
+ {
+ aPos = *pPos;
+ }
+ else
+ {
+ Rectangle aRect(aPos, GetActiveWindow()->GetOutputSizePixel() );
+ aPos = aRect.Center();
+ aPos = GetActiveWindow()->PixelToLogic(aPos);
+ aPos.X() -= aSize.Width() / 2;
+ aPos.Y() -= aSize.Height() / 2;
+ }
+
+ Rectangle aLogicRect(aPos, aSize);
+ pRectObj->SetLogicRect(aLogicRect);
+ pRectObj->SetOutlinerParaObject( pOutlParaObject );
+ mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView());
+ pOutl->Init( nOutlMode );
+ }
+}
+
+/*************************************************************************
+|*
+|* URL-Button einfuegen
+|*
+\************************************************************************/
+
+void DrawViewShell::InsertURLButton(const String& rURL, const String& rText,
+ const String& rTarget, const Point* pPos)
+{
+ sal_Bool bNewObj = sal_True;
+
+ const OUString sTargetURL( ::URIHelper::SmartRel2Abs( INetURLObject( GetDocSh()->GetMedium()->GetBaseURL() ), rURL, URIHelper::GetMaybeFileHdl(), true, false,
+ INetURLObject::WAS_ENCODED,
+ INetURLObject::DECODE_UNAMBIGUOUS ) );
+ if (mpDrawView->GetMarkedObjectList().GetMarkCount() > 0)
+ {
+ SdrObject* pMarkedObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ if( pMarkedObj ) try
+ {
+ // change first marked object
+ if( (FmFormInventor == pMarkedObj->GetObjInventor() && pMarkedObj->GetObjIdentifier() == OBJ_FM_BUTTON) )
+ {
+ bNewObj = sal_False;
+
+ SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( pMarkedObj );
+
+ Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), UNO_QUERY_THROW );
+ Reference< beans::XPropertySet > xPropSet( xControlModel, UNO_QUERY_THROW );
+
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" )), Any( OUString( rText ) ) );
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" )), Any( sTargetURL ) );
+
+ if( rTarget.Len() )
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" )), Any( OUString( rTarget ) ) );
+
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" )), Any( form::FormButtonType_URL ) );
+ if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
+ {
+ // #105638# OJ
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), Any( sal_True ) );
+ }
+ }
+ else
+ {
+ // add url as interaction for first selected shape
+ bNewObj = sal_False;
+
+ SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pMarkedObj, true);
+ pInfo->meClickAction = presentation::ClickAction_DOCUMENT;
+ pInfo->SetBookmark( sTargetURL );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ if (bNewObj) try
+ {
+ SdrUnoObj* pUnoCtrl = static_cast< SdrUnoObj* >( SdrObjFactory::MakeNewObject(FmFormInventor, OBJ_FM_BUTTON,
+ mpDrawView->GetSdrPageView()->GetPage(), GetDoc()) );
+
+ Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
+ Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
+
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "Label" )), Any( OUString( rText ) ) );
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetURL" )), Any( sTargetURL ) );
+
+ if( rTarget.Len() )
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" )), Any( OUString( rTarget ) ) );
+
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" )), Any( form::FormButtonType_URL ) );
+ // #105638# OJ
+ if ( ::avmedia::MediaWindow::isMediaURL( rURL ) )
+ xPropSet->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), Any( sal_True ) );
+
+ Point aPos;
+
+ if (pPos)
+ {
+ aPos = *pPos;
+ }
+ else
+ {
+ aPos = Rectangle(aPos, GetActiveWindow()->GetOutputSizePixel()).Center();
+ aPos = GetActiveWindow()->PixelToLogic(aPos);
+ }
+
+ Size aSize(4000, 1000);
+ aPos.X() -= aSize.Width() / 2;
+ aPos.Y() -= aSize.Height() / 2;
+ pUnoCtrl->SetLogicRect(Rectangle(aPos, aSize));
+
+ sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
+
+ OSL_ASSERT (GetViewShell()!=NULL);
+ SfxInPlaceClient* pIpClient = GetViewShell()->GetIPClient();
+ if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
+ {
+ nOptions |= SDRINSERT_DONTMARK;
+ }
+
+ mpDrawView->InsertObjectAtView(pUnoCtrl, *mpDrawView->GetSdrPageView(), nOptions);
+ }
+ catch( Exception& )
+ {
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void DrawViewShell::ShowUIControls (bool bVisible)
+{
+ ViewShell::ShowUIControls (bVisible);
+
+ //AF: The LayerDialogChildWindow is not used anymore (I hope).
+ // GetViewFrame()->SetChildWindow(
+ // LayerDialogChildWindow::GetChildWindowId(),
+ // IsLayerModeActive() && bVisible);
+ maTabControl.Show (bVisible);
+}
+
+void DrawViewShell::StopSlideShow (bool /*bCloseFrame*/)
+{
+ Reference< XPresentation2 > xPresentation( GetDoc()->getPresentation() );
+ if(xPresentation.is() && xPresentation->isRunning())
+ {
+ if( mpDrawView->IsTextEdit() )
+ mpDrawView->SdrEndTextEdit();
+
+ xPresentation->end();
+ }
+}
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
new file mode 100755
index 000000000000..84540e65d05e
--- /dev/null
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -0,0 +1,576 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#ifndef _GLOBL3D_HXX
+#include <svx/globl3d.hxx>
+#endif
+#include <svx/hlnkitem.hxx>
+#include <editeng/eeitem.hxx>
+#ifndef _FLDITEM_HXX
+#include <editeng/flditem.hxx>
+#endif
+#include <sfx2/viewfrm.hxx>
+#include <svl/whiter.hxx>
+#include <svl/eitem.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/tplpitem.hxx>
+#ifndef _BINDING_HXX //autogen
+#include <sfx2/bindings.hxx>
+#endif
+#include <sfx2/app.hxx>
+#include <sfx2/templdlg.hxx>
+#include <svx/xdef.hxx>
+#include <svx/svddef.hxx>
+#include <svx/fmglob.hxx>
+#include <svx/svdouno.hxx>
+#include <tools/urlobj.hxx>
+#include <svx/fmshell.hxx>
+#include <svl/cjkoptions.hxx>
+
+#ifndef SD_FRAME_VIEW
+#include "FrameView.hxx"
+#endif
+#include "Outliner.hxx"
+#include "app.hrc"
+
+#include "app.hxx"
+#include "stlsheet.hxx"
+#include "drawview.hxx"
+#include "drawdoc.hxx"
+#include "Window.hxx"
+#include "ViewShellBase.hxx"
+#include "FormShellManager.hxx"
+#include "cfgids.hxx"
+#include "anminfo.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Status von Controller-SfxSlots setzen
+|*
+\************************************************************************/
+
+void DrawViewShell::GetCtrlState(SfxItemSet &rSet)
+{
+ if (rSet.GetItemState(SID_RELOAD) != SFX_ITEM_UNKNOWN)
+ {
+ // "Letzte Version" vom SFx en/disablen lassen
+ GetViewFrame()->GetSlotState (SID_RELOAD, NULL, &rSet);
+ }
+
+ if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_HYPERLINK_GETLINK))
+ {
+ SvxHyperlinkItem aHLinkItem;
+
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+
+ if (pOLV)
+ {
+ bool bField = false;
+ const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ ESelection aSel = pOLV->GetSelection();
+ if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if (pField->ISA(SvxURLField))
+ {
+ aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
+ aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
+ aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
+ bField = true;
+ }
+ }
+ }
+ if (!bField)
+ {
+ // use selected text as name for urls
+ String sReturn = pOLV->GetSelected();
+ sReturn.Erase(255);
+ sReturn.EraseTrailingChars();
+ aHLinkItem.SetName(sReturn);
+ }
+ }
+ else
+ {
+ if (mpDrawView->GetMarkedObjectList().GetMarkCount() > 0)
+ {
+ bool bFound = false;
+
+ SdrObject* pMarkedObj = mpDrawView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj();
+ if( pMarkedObj && (FmFormInventor == pMarkedObj->GetObjInventor()) )
+ {
+ SdrUnoObj* pUnoCtrl = dynamic_cast< SdrUnoObj* >( pMarkedObj );
+
+ if(pUnoCtrl) try
+ {
+ uno::Reference< awt::XControlModel > xControlModel( pUnoCtrl->GetUnoControlModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySetInfo > xPropInfo( xPropSet->getPropertySetInfo(), uno::UNO_QUERY_THROW );
+
+ form::FormButtonType eButtonType = form::FormButtonType_URL;
+ const OUString sButtonType( RTL_CONSTASCII_USTRINGPARAM( "ButtonType" ) );
+ if(xPropInfo->hasPropertyByName( sButtonType ) && (xPropSet->getPropertyValue( sButtonType ) >>= eButtonType ) )
+ {
+ OUString aString;
+
+ // Label
+ const OUString sLabel( RTL_CONSTASCII_USTRINGPARAM( "Label" ) );
+ if(xPropInfo->hasPropertyByName(sLabel))
+ {
+ if( xPropSet->getPropertyValue(sLabel) >>= aString )
+ aHLinkItem.SetName(String( aString ));
+ }
+
+ // URL
+ const OUString sTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" ));
+ if(xPropInfo->hasPropertyByName(sTargetURL))
+ {
+ if( xPropSet->getPropertyValue(sTargetURL) >>= aString )
+ aHLinkItem.SetURL(String( aString ));
+ }
+
+ // Target
+ const OUString sTargetFrame( RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" ) );
+ if(xPropInfo->hasPropertyByName(sTargetFrame) )
+ {
+ if( xPropSet->getPropertyValue(sTargetFrame) >>= aString )
+ aHLinkItem.SetTargetFrame(String( aString ));
+ }
+
+ aHLinkItem.SetInsertMode(HLINK_BUTTON);
+ bFound = true;
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ // try interaction link
+ if( !bFound && pMarkedObj )
+ {
+ SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pMarkedObj);
+ if( pInfo && (pInfo->meClickAction == presentation::ClickAction_DOCUMENT) )
+ aHLinkItem.SetURL( pInfo->GetBookmark());
+ aHLinkItem.SetInsertMode(HLINK_BUTTON);
+ }
+ }
+ }
+
+ rSet.Put(aHLinkItem);
+ }
+ rSet.Put( SfxBoolItem( SID_READONLY_MODE, mbReadOnly ) );
+
+ // Ausgabequalitaet
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_COLOR ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_GRAYSCALE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_BLACKWHITE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OUTPUT_QUALITY_CONTRAST ) )
+ {
+ const sal_uLong nMode = (sal_Int32)GetActiveWindow()->GetDrawMode();
+ rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_COLOR, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_COLOR == nMode) ) );
+ rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_GRAYSCALE, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_GRAYSCALE == nMode) ) );
+ rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_BLACKWHITE, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_BLACKWHITE == nMode) ) );
+ rSet.Put( SfxBoolItem( SID_OUTPUT_QUALITY_CONTRAST, (sal_Bool)((sal_uLong)OUTPUT_DRAWMODE_CONTRAST == nMode) ) );
+ }
+
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
+ {
+ rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, sal_True ) );
+ }
+
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_ATTR_YEAR2000) )
+ {
+ FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
+ if (pFormShell != NULL)
+ {
+ sal_uInt16 nState = 0;
+ if (pFormShell->GetY2KState(nState))
+ rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nState ) );
+ else
+ rSet.DisableItem( SID_ATTR_YEAR2000 );
+ }
+ }
+
+ if ( !GetView()->GetTextEditOutliner() )
+ {
+ SvtCJKOptions aCJKOptions;
+ if( !aCJKOptions.IsChangeCaseMapEnabled() )
+ {
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False );
+ }
+ else
+ {
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True );
+ }
+
+ rSet.DisableItem( SID_TRANSLITERATE_SENTENCE_CASE );
+ rSet.DisableItem( SID_TRANSLITERATE_TITLE_CASE );
+ rSet.DisableItem( SID_TRANSLITERATE_TOGGLE_CASE );
+ rSet.DisableItem( SID_TRANSLITERATE_UPPER );
+ rSet.DisableItem( SID_TRANSLITERATE_LOWER );
+ rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
+ rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
+ rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
+ rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
+ }
+ else
+ {
+ SvtCJKOptions aCJKOptions;
+ if( !aCJKOptions.IsChangeCaseMapEnabled() )
+ {
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False );
+ rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
+ rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
+ rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
+ rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
+ }
+ else
+ {
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True );
+ }
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Status der Attribut-Items
+|*
+\************************************************************************/
+
+void DrawViewShell::GetAttrState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+
+ sal_Bool bAttr = sal_False;
+ SfxAllItemSet aAllSet( *rSet.GetPool() );
+
+ while ( nWhich )
+ {
+ sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
+ ? GetPool().GetSlotId(nWhich)
+ : nWhich;
+ switch ( nSlotId )
+ {
+ case SID_ATTR_FILL_STYLE:
+ case SID_ATTR_FILL_COLOR:
+ case SID_ATTR_FILL_GRADIENT:
+ case SID_ATTR_FILL_HATCH:
+ case SID_ATTR_FILL_BITMAP:
+ case SID_ATTR_FILL_SHADOW:
+ case SID_ATTR_LINE_STYLE:
+ case SID_ATTR_LINE_DASH:
+ case SID_ATTR_LINE_WIDTH:
+ case SID_ATTR_LINE_COLOR:
+ case SID_ATTR_TEXT_FITTOSIZE:
+ {
+ bAttr = sal_True;
+ }
+ break;
+
+ case SID_HYPHENATION:
+ {
+ SfxItemSet aAttrs( GetDoc()->GetPool() );
+ mpDrawView->GetAttributes( aAttrs );
+ if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
+ {
+ sal_Bool bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue();
+ rSet.Put( SfxBoolItem( SID_HYPHENATION, bValue ) );
+ }
+ }
+ break;
+
+ case SID_STYLE_FAMILY2:
+ case SID_STYLE_FAMILY3:
+ case SID_STYLE_FAMILY5:
+ case SID_STYLE_APPLY: // StyleControl
+ {
+ SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
+ if( pStyleSheet )
+ {
+ if( nSlotId != SID_STYLE_APPLY && !mpDrawView->AreObjectsMarked() )
+ {
+ SfxTemplateItem aTmpItem( nWhich, String() );
+ aAllSet.Put( aTmpItem, aTmpItem.Which() );
+ }
+ else
+ {
+ if (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
+ pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
+
+ if( pStyleSheet )
+ {
+ SfxStyleFamily eFamily = pStyleSheet->GetFamily();
+
+ if ((eFamily == SD_STYLE_FAMILY_GRAPHICS && nSlotId == SID_STYLE_FAMILY2) ||
+ (eFamily == SD_STYLE_FAMILY_CELL && nSlotId == SID_STYLE_FAMILY3) ||
+ (eFamily == SD_STYLE_FAMILY_PSEUDO && nSlotId == SID_STYLE_FAMILY5))
+ {
+ SfxTemplateItem aTmpItem ( nWhich, pStyleSheet->GetName() );
+ aAllSet.Put( aTmpItem, aTmpItem.Which() );
+ }
+ else
+ {
+ SfxTemplateItem aTmpItem(nWhich, String());
+ aAllSet.Put(aTmpItem,aTmpItem.Which() );
+ }
+ }
+ }
+ }
+ else
+ { SfxTemplateItem aItem( nWhich, String() );
+ aAllSet.Put( aItem, aItem.Which() );
+ // rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_SET_DEFAULT:
+ {
+ if( !mpDrawView->GetMarkedObjectList().GetMarkCount() ||
+ ( !mpDrawView->IsTextEdit() && !mpDrawView->GetStyleSheet() )
+ )
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_STYLE_WATERCAN:
+ {
+ ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
+ if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ rSet.Put(SfxBoolItem(nWhich,sal_False));
+ else
+ {
+ SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
+ aAllSet.Put( aItem, aItem.Which());
+ }
+ }
+ break;
+
+ case SID_STYLE_NEW:
+ {
+ ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
+ if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case SID_STYLE_DRAGHIERARCHIE:
+ {
+ ISfxTemplateCommon* pTemplateCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
+ if (pTemplateCommon && pTemplateCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ {
+ // PseudoStyleSheets koennen nicht 'by Example' erzeugt werden;
+ // normale StyleSheets brauchen dafuer ein selektiertes Objekt
+ ISfxTemplateCommon* pTemplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
+ if (pTemplCommon)
+ {
+ if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ {
+ rSet.DisableItem(nWhich);
+ }
+ else if (pTemplCommon->GetActualFamily() == SD_STYLE_FAMILY_GRAPHICS)
+ {
+ if (!mpDrawView->AreObjectsMarked())
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ }
+ // falls (noch) kein Gestalter da ist, muessen wir uns auf den
+ // View-Zustand zurueckziehen; eine aktuell eingestellte Familie
+ // kann nicht beruecksichtigt werden
+ else
+ {
+ if (!mpDrawView->AreObjectsMarked())
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+
+ }
+ break;
+
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ {
+ if (!mpDrawView->AreObjectsMarked())
+ {
+ rSet.DisableItem(nWhich);
+ }
+ }
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+
+ SfxItemSet* pSet = NULL;
+
+ if( bAttr )
+ {
+ pSet = new SfxItemSet( GetDoc()->GetPool() );
+ mpDrawView->GetAttributes( *pSet );
+ rSet.Put( *pSet, sal_False );
+ }
+
+ rSet.Put( aAllSet, sal_False );
+
+ // Flaechen und/oder Linienattribute wurden geaendert
+ if( bAttr && pSet )
+ {
+ // Wenn die View selektierte Objekte besitzt, muessen entspr. Items
+ // von SFX_ITEM_DEFAULT (_ON) auf SFX_ITEM_DISABLED geaendert werden
+ if( mpDrawView->AreObjectsMarked() )
+ {
+ SfxWhichIter aNewIter( *pSet, XATTR_LINE_FIRST, XATTR_FILL_LAST );
+ nWhich = aNewIter.FirstWhich();
+ while( nWhich )
+ {
+ if( SFX_ITEM_DEFAULT == pSet->GetItemState( nWhich ) )
+ {
+ rSet.ClearItem( nWhich );
+ rSet.DisableItem( nWhich );
+ }
+ nWhich = aNewIter.NextWhich();
+ }
+ }
+ delete pSet;
+ }
+
+// const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+// sal_uLong nMarkCount = rMarkList.GetMarkCount();
+// sal_Bool bDisabled = sal_False;
+//
+// for (sal_uLong i = 0;
+// i < nMarkCount && !bDisabled && i < 50; i++)
+// {
+// SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+//
+// if (pObj->GetObjInventor() == E3dInventor)
+// {
+// bDisabled = sal_True;
+// rSet.ClearItem(SDRATTR_SHADOW);
+// rSet.DisableItem(SDRATTR_SHADOW);
+// }
+// }
+}
+
+
+/*************************************************************************
+|*
+|* Text der Selektion zurueckgeben
+|*
+\************************************************************************/
+
+String DrawViewShell::GetSelectionText(sal_Bool bCompleteWords)
+{
+ String aStrSelection;
+ ::Outliner* pOl = mpDrawView->GetTextEditOutliner();
+ OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
+
+ if (pOl && pOlView)
+ {
+ if (bCompleteWords)
+ {
+ ESelection aSel = pOlView->GetSelection();
+ String aStrCurrentDelimiters = pOl->GetWordDelimiters();
+
+ pOl->SetWordDelimiters( String( RTL_CONSTASCII_USTRINGPARAM( " .,;\"'" )));
+ aStrSelection = pOl->GetWord( aSel.nEndPara, aSel.nEndPos );
+ pOl->SetWordDelimiters( aStrCurrentDelimiters );
+ }
+ else
+ {
+ aStrSelection = pOlView->GetSelected();
+ }
+ }
+
+ return (aStrSelection);
+}
+
+/*************************************************************************
+|*
+|* Ist etwas selektiert?
+|*
+\************************************************************************/
+
+sal_Bool DrawViewShell::HasSelection(sal_Bool bText) const
+{
+ sal_Bool bReturn = sal_False;
+
+ if (bText)
+ {
+ OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
+
+ if (pOlView && pOlView->GetSelected().Len() != 0)
+ {
+ bReturn = sal_True;
+ }
+ }
+ else if (mpDrawView->GetMarkedObjectList().GetMarkCount() != 0)
+ {
+ bReturn = sal_True;
+ }
+
+ return bReturn;
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviewsg.cxx b/sd/source/ui/view/drviewsg.cxx
new file mode 100755
index 000000000000..f09eaf8dd483
--- /dev/null
+++ b/sd/source/ui/view/drviewsg.cxx
@@ -0,0 +1,296 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include "ViewShellImplementation.hxx"
+
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#ifndef _IMAPDLG_HXX
+#include <svx/imapdlg.hxx>
+#endif
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+
+
+#include "app.hrc"
+
+#include "drawdoc.hxx"
+#include "slideshow.hxx"
+#include "imapinfo.hxx"
+#include "sdmod.hxx"
+#include "optsitem.hxx"
+#ifndef SD_FRAME_VIEW
+#include "FrameView.hxx"
+#endif
+#include "drawview.hxx"
+
+#include "fupoor.hxx"
+
+namespace sd {
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecIMap( SfxRequest& rReq )
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if(HasCurrentFunction(SID_PRESENTATION) )
+ return;
+
+ if ( rReq.GetSlot() == SID_IMAP_EXEC )
+ {
+ SdrMark* pMark = mpDrawView->GetMarkedObjectList().GetMark(0);
+
+ if ( pMark )
+ {
+ SdrObject* pSdrObj = pMark->GetMarkedSdrObj();
+ SvxIMapDlg* pDlg = ViewShell::Implementation::GetImageMapDialog();
+
+ if ( pDlg->GetEditingObject() == (void*) pSdrObj )
+ {
+ const ImageMap& rImageMap = pDlg->GetImageMap();
+ SdIMapInfo* pIMapInfo = GetDoc()->GetIMapInfo( pSdrObj );
+
+ if ( !pIMapInfo )
+ pSdrObj->InsertUserData( new SdIMapInfo( rImageMap ) );
+ else
+ pIMapInfo->SetImageMap( rImageMap );
+
+ GetDoc()->SetChanged( sal_True );
+ }
+ }
+ }
+}
+
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+void DrawViewShell::GetIMapState( SfxItemSet& rSet )
+{
+ sal_Bool bDisable = sal_True;
+
+ if( GetViewFrame()->HasChildWindow( SvxIMapDlgChildWindow::GetChildWindowId() ) )
+ {
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ const SdrObject* pObj = NULL;
+ sal_uLong nMarkCount = rMarkList.GetMarkCount();
+
+ if ( nMarkCount == 1 )
+ {
+ pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ SvxIMapDlg* pImageMapDialog = ViewShell::Implementation::GetImageMapDialog();
+ if ( ( pObj->ISA( SdrGrafObj ) /*|| pObj->ISA( SdrOle2Obj )*/ )
+ && pImageMapDialog!=NULL
+ && ( pImageMapDialog->GetEditingObject() == (void*) pObj ) )
+ {
+ bDisable = sal_False;
+ }
+ }
+ }
+
+ rSet.Put( SfxBoolItem( SID_IMAP_EXEC, bDisable ) );
+}
+
+/*************************************************************************
+|*
+|* Execute-Methode der Optionsleiste
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecOptionsBar( SfxRequest& rReq )
+{
+ // waehrend einer Diashow wird nichts ausgefuehrt!
+ if(HasCurrentFunction(SID_PRESENTATION))
+ return;
+
+ sal_Bool bDefault = sal_False;
+ sal_uInt16 nSlot = rReq.GetSlot();
+
+ SdOptions* pOptions = SD_MOD()->GetSdOptions(GetDoc()->GetDocumentType());
+
+ switch( nSlot )
+ {
+ case SID_HANDLES_DRAFT:
+ pOptions->SetSolidMarkHdl( !mpDrawView->IsSolidMarkHdl() );
+ break;
+
+ case SID_SOLID_CREATE:
+ pOptions->SetSolidDragging( !mpDrawView->IsSolidDragging() );
+ break;
+
+
+ // Raster- / Hilfslinien-Optionen
+ case SID_GRID_VISIBLE: // noch nicht hier !
+ {
+ pOptions->SetGridVisible( !mpDrawView->IsGridVisible() );
+ }
+ break;
+
+ case SID_GRID_USE:
+ {
+ pOptions->SetUseGridSnap( !mpDrawView->IsGridSnap() );
+ }
+ break;
+
+ case SID_HELPLINES_VISIBLE: // noch nicht hier !
+ {
+ pOptions->SetHelplines( !mpDrawView->IsHlplVisible() );
+ }
+ break;
+
+ case SID_HELPLINES_USE:
+ {
+ pOptions->SetSnapHelplines( !mpDrawView->IsHlplSnap() );
+ }
+ break;
+
+ case SID_HELPLINES_MOVE:
+ {
+ pOptions->SetDragStripes( !mpDrawView->IsDragStripes() );
+ }
+ break;
+
+
+ case SID_SNAP_BORDER:
+ {
+ pOptions->SetSnapBorder( !mpDrawView->IsBordSnap() );
+ }
+ break;
+
+ case SID_SNAP_FRAME:
+ {
+ pOptions->SetSnapFrame( !mpDrawView->IsOFrmSnap() );
+ }
+ break;
+
+ case SID_SNAP_POINTS:
+ {
+ pOptions->SetSnapPoints( !mpDrawView->IsOPntSnap() );
+ }
+ break;
+
+
+ case SID_QUICKEDIT:
+ {
+ pOptions->SetQuickEdit( !mpDrawView->IsQuickTextEditMode() );
+ }
+ break;
+
+ case SID_PICK_THROUGH:
+ {
+ pOptions->SetPickThrough(
+ !mpDrawView->GetModel()->IsPickThroughTransparentTextFrames() );
+ }
+ break;
+
+ case SID_BIG_HANDLES:
+ {
+ pOptions->SetBigHandles( !mpFrameView->IsBigHandles() );
+ }
+ break;
+
+ case SID_DOUBLECLICK_TEXTEDIT:
+ {
+ pOptions->SetDoubleClickTextEdit( !mpFrameView->IsDoubleClickTextEdit() );
+ }
+ break;
+
+ case SID_CLICK_CHANGE_ROTATION:
+ {
+ pOptions->SetClickChangeRotation( !mpFrameView->IsClickChangeRotation() );
+ }
+ break;
+
+ default:
+ bDefault = sal_True;
+ break;
+ }
+
+ if( !bDefault )
+ {
+ pOptions->StoreConfig();
+
+ // Speichert die Konfiguration SOFORT
+ // SFX_APP()->SaveConfiguration();
+ WriteFrameViewData();
+
+ mpFrameView->Update( pOptions );
+ ReadFrameViewData( mpFrameView );
+
+ Invalidate( nSlot );
+ rReq.Done();
+ }
+
+}
+
+
+/*************************************************************************
+|*
+|* State-Methode der Optionsleiste
+|*
+\************************************************************************/
+
+void DrawViewShell::GetOptionsBarState( SfxItemSet& rSet )
+{
+ rSet.Put( SfxBoolItem( SID_HANDLES_DRAFT, !mpDrawView->IsSolidMarkHdl() ) );
+ rSet.Put( SfxBoolItem( SID_SOLID_CREATE, mpDrawView->IsSolidDragging() ) );
+ rSet.Put( SfxBoolItem( SID_GRID_VISIBLE, mpDrawView->IsGridVisible() ) );
+ rSet.Put( SfxBoolItem( SID_GRID_USE, mpDrawView->IsGridSnap() ) );
+ rSet.Put( SfxBoolItem( SID_HELPLINES_VISIBLE, mpDrawView->IsHlplVisible() ) );
+ rSet.Put( SfxBoolItem( SID_HELPLINES_USE, mpDrawView->IsHlplSnap() ) );
+ rSet.Put( SfxBoolItem( SID_HELPLINES_MOVE, mpDrawView->IsDragStripes() ) );
+
+ rSet.Put( SfxBoolItem( SID_SNAP_BORDER, mpDrawView->IsBordSnap() ) );
+ rSet.Put( SfxBoolItem( SID_SNAP_FRAME, mpDrawView->IsOFrmSnap() ) );
+ rSet.Put( SfxBoolItem( SID_SNAP_POINTS, mpDrawView->IsOPntSnap() ) );
+
+ rSet.Put( SfxBoolItem( SID_QUICKEDIT, mpDrawView->IsQuickTextEditMode() ) );
+ rSet.Put( SfxBoolItem( SID_PICK_THROUGH, (sal_Bool)
+ mpDrawView->GetModel()->IsPickThroughTransparentTextFrames() ) );
+
+ rSet.Put( SfxBoolItem( SID_BIG_HANDLES, mpFrameView->IsBigHandles() ) );
+ rSet.Put( SfxBoolItem( SID_DOUBLECLICK_TEXTEDIT, mpFrameView->IsDoubleClickTextEdit() ) );
+ rSet.Put( SfxBoolItem( SID_CLICK_CHANGE_ROTATION, mpFrameView->IsClickChangeRotation() ) );
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drviewsh.cxx b/sd/source/ui/view/drviewsh.cxx
new file mode 100755
index 000000000000..2fc5c02babc4
--- /dev/null
+++ b/sd/source/ui/view/drviewsh.cxx
@@ -0,0 +1,193 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include <svl/aeitem.hxx>
+#include <svl/itemset.hxx>
+#include <sfx2/request.hxx>
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+
+
+#include <svx/fmshell.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include "app.hrc"
+#include "strings.hrc"
+#include "sdpage.hxx"
+#ifndef SD_FRAME_VIEW
+#include "FrameView.hxx"
+#endif
+#include "sdresid.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "Window.hxx"
+#include "GraphicViewShell.hxx"
+#include "drawview.hxx"
+
+#include "slideshow.hxx"
+
+namespace sd {
+
+#define TABCONTROL_INITIAL_SIZE 500
+
+/*************************************************************************
+|*
+|* Sprung zu Bookmark
+|*
+\************************************************************************/
+
+sal_Bool DrawViewShell::GotoBookmark(const String& rBookmark)
+{
+ sal_Bool bRet = sal_False;
+ ::sd::DrawDocShell* pDocSh = GetDocSh();
+ if( pDocSh )
+ {
+ if( !pDocSh->GetViewShell() ) //#i26016# this case occurs if the jump-target-document was opened already with file open dialog before triggering the jump via hyperlink
+ pDocSh->Connect(this);
+ bRet = (pDocSh->GotoBookmark(rBookmark));
+ }
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|* Bereich sichtbar machen (Bildausschnitt scrollen)
+|*
+\************************************************************************/
+
+void DrawViewShell::MakeVisible(const Rectangle& rRect, ::Window& rWin)
+{
+ // #98568# In older versions, if in X or Y the size of the object was
+ // smaller than the visible area, the user-defined zoom was
+ // changed. This was decided to be a bug for 6.x, thus I developed a
+ // version which instead handles X/Y bigger/smaller and visibility
+ // questions seperately. The new behaviour is triggered with the
+ // bZoomAllowed parameter which for old behaviour should be set to
+ // sal_True. I looked at all uses of MakeVisible() in the application
+ // and found no valid reason for really changing the zoom factor, thus I
+ // decided to NOT expand (incompatible) this virtual method to get one
+ // more parameter. If this is wanted in later versions, feel free to add
+ // that bool to the parameter list.
+ sal_Bool bZoomAllowed(sal_False);
+ Size aLogicSize(rRect.GetSize());
+
+ // Sichtbarer Bereich
+ Size aVisSizePixel(rWin.GetOutputSizePixel());
+ Rectangle aVisArea(rWin.PixelToLogic(Rectangle(Point(0,0), aVisSizePixel)));
+ Size aVisAreaSize(aVisArea.GetSize());
+
+ if(!aVisArea.IsInside(rRect) && !SlideShow::IsRunning( GetViewShellBase() ) )
+ {
+ // Objekt liegt nicht komplett im sichtbaren Bereich
+ sal_Int32 nFreeSpaceX(aVisAreaSize.Width() - aLogicSize.Width());
+ sal_Int32 nFreeSpaceY(aVisAreaSize.Height() - aLogicSize.Height());
+
+ if(bZoomAllowed && (nFreeSpaceX < 0 || nFreeSpaceY < 0))
+ {
+ // Objekt passt nicht in sichtbaren Bereich -> auf Objektgroesse zoomen
+ SetZoomRect(rRect);
+ }
+ else
+ {
+ // #98568# allow a mode for move-only visibility without zooming.
+ const sal_Int32 nPercentBorder(30);
+ const Rectangle aInnerRectangle(
+ aVisArea.Left() + ((aVisAreaSize.Width() * nPercentBorder) / 200),
+ aVisArea.Top() + ((aVisAreaSize.Height() * nPercentBorder) / 200),
+ aVisArea.Right() - ((aVisAreaSize.Width() * nPercentBorder) / 200),
+ aVisArea.Bottom() - ((aVisAreaSize.Height() * nPercentBorder) / 200)
+ );
+ Point aNewPos(aVisArea.TopLeft());
+
+ if(nFreeSpaceX < 0)
+ {
+ if(aInnerRectangle.Left() > rRect.Right())
+ {
+ // object moves out to the left
+ aNewPos.X() -= aVisAreaSize.Width() / 2;
+ }
+
+ if(aInnerRectangle.Right() < rRect.Left())
+ {
+ // object moves out to the right
+ aNewPos.X() += aVisAreaSize.Width() / 2;
+ }
+ }
+ else
+ {
+ if(nFreeSpaceX > rRect.GetWidth())
+ nFreeSpaceX = rRect.GetWidth();
+
+ while(rRect.Right() > aNewPos.X() + aVisAreaSize.Width())
+ aNewPos.X() += nFreeSpaceX;
+
+ while(rRect.Left() < aNewPos.X())
+ aNewPos.X() -= nFreeSpaceX;
+ }
+
+ if(nFreeSpaceY < 0)
+ {
+ if(aInnerRectangle.Top() > rRect.Bottom())
+ {
+ // object moves out to the top
+ aNewPos.Y() -= aVisAreaSize.Height() / 2;
+ }
+
+ if(aInnerRectangle.Bottom() < rRect.Top())
+ {
+ // object moves out to the right
+ aNewPos.Y() += aVisAreaSize.Height() / 2;
+ }
+ }
+ else
+ {
+ if(nFreeSpaceY > rRect.GetHeight())
+ nFreeSpaceY = rRect.GetHeight();
+
+ while(rRect.Bottom() > aNewPos.Y() + aVisAreaSize.Height())
+ aNewPos.Y() += nFreeSpaceY;
+
+ while(rRect.Top() < aNewPos.Y())
+ aNewPos.Y() -= nFreeSpaceY;
+ }
+
+ // did position change? Does it need to be set?
+ if(aNewPos != aVisArea.TopLeft())
+ {
+ aVisArea.SetPos(aNewPos);
+ SetZoomRect(aVisArea);
+ }
+ }
+ }
+}
+
+}
diff --git a/sd/source/ui/view/drviewsi.cxx b/sd/source/ui/view/drviewsi.cxx
new file mode 100755
index 000000000000..d91dcf6f8da6
--- /dev/null
+++ b/sd/source/ui/view/drviewsi.cxx
@@ -0,0 +1,207 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include <svx/xtable.hxx>
+#include "sdattr.hxx"
+#include <svl/aeitem.hxx>
+#include <editeng/eeitem.hxx>
+#include <sfx2/request.hxx>
+#include <svx/svditer.hxx>
+#include <editeng/colritem.hxx>
+#include <sfx2/viewfrm.hxx>
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svx/svdundo.hxx>
+#include <svx/view3d.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/float3d.hxx>
+#include <svx/f3dchild.hxx>
+#ifndef _SVX_DIALOGS_HRC //autogen
+#include <svx/dialogs.hrc>
+#endif
+#include <vcl/msgbox.hxx>
+
+
+#include "app.hrc"
+#include "strings.hrc"
+
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "anminfo.hxx"
+#include "unoaprms.hxx" // Undo-Action
+#include "sdundogr.hxx" // Undo Gruppe
+#include "drawview.hxx"
+#include "Window.hxx"
+#include "sdresid.hxx"
+
+using namespace ::com::sun::star;
+
+namespace sd {
+
+#define ATTR_MISSING 0 // Attribut nicht verfuegbar
+#define ATTR_MIXED 1 // Attribut uneindeutig (bei Mehrfachselektion)
+#define ATTR_SET 2 // Attribut eindeutig
+
+#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue()
+
+/*************************************************************************
+|*
+|* SfxRequests fuer EffekteWindow bearbeiten
+|*
+\************************************************************************/
+
+void DrawViewShell::ExecEffectWin( SfxRequest& rReq )
+{
+ CheckLineTo (rReq);
+
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ switch( nSId )
+ {
+ case SID_3D_INIT:
+ {
+ sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
+ SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
+ if( pWindow )
+ {
+ Svx3DWin* p3DWin = (Svx3DWin*)( pWindow->GetWindow() );
+ if( p3DWin )
+ p3DWin->InitColorLB( GetDoc() );
+ }
+ }
+ break;
+
+ case SID_3D_STATE:
+ {
+ Update3DWindow();
+ }
+ break;
+
+ case SID_3D_ASSIGN:
+ {
+ AssignFrom3DWindow();
+ }
+ break;
+
+ }
+}
+
+/*************************************************************************
+|*
+|* 3D - Assign / Update
+|*
+\************************************************************************/
+void DrawViewShell::Update3DWindow()
+{
+ sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
+ SfxChildWindow* pWindow = GetViewFrame()->GetChildWindow( nId );
+ if( pWindow )
+ {
+ Svx3DWin* p3DWin = (Svx3DWin*) pWindow->GetWindow();
+ if( p3DWin && p3DWin->IsUpdateMode() )
+ {
+ SfxItemSet aTmpItemSet = GetView()->Get3DAttributes();
+ p3DWin->Update( aTmpItemSet );
+ }
+ }
+}
+
+/*----------------------------------------------------------------------------*/
+
+void DrawViewShell::AssignFrom3DWindow()
+{
+ sal_uInt16 nId = Svx3DChildWindow::GetChildWindowId();
+ SfxChildWindow* pWin = GetViewFrame()->GetChildWindow( nId );
+ if( pWin )
+ {
+ Svx3DWin* p3DWin = (Svx3DWin*) pWin->GetWindow();
+ if( p3DWin && GetView() )
+ {
+ if(!GetView()->IsPresObjSelected())
+ {
+ SfxItemSet aSet( GetDoc()->GetPool(),
+ SDRATTR_START, SDRATTR_END,
+ 0, 0);
+ p3DWin->GetAttr( aSet );
+
+ // Eigene UNDO-Klammerung auch um die Wandlung in 3D
+ GetView()->BegUndo(String(SdResId(STR_UNDO_APPLY_3D_FAVOURITE)));
+
+ if(GetView()->IsConvertTo3DObjPossible())
+ {
+ // Nur TextAttribute zuweisen
+ SfxItemSet aTextSet( GetDoc()->GetPool(),
+ EE_ITEMS_START, EE_ITEMS_END, 0 );
+ aTextSet.Put( aSet, sal_False );
+ GetView()->SetAttributes( aTextSet );
+
+ // Text in 3D umwandeln
+ sal_uInt16 nSId = SID_CONVERT_TO_3D;
+ SfxBoolItem aItem( nSId, sal_True );
+ GetViewFrame()->GetDispatcher()->Execute(
+ nSId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+
+ // Feststellen, ob ein FILL_Attribut gesetzt ist.
+ // Falls nicht, Fuellattribut hart setzen
+ XFillStyle eFillStyle = ITEMVALUE( aSet, XATTR_FILLSTYLE, XFillStyleItem );
+ if(eFillStyle == XFILL_NONE)
+ aSet.Put(XFillStyleItem (XFILL_SOLID));
+
+ // remove some 3DSCENE attributes since these were
+ // created by convert to 3D and may not be changed
+ // to the defaults again.
+ aSet.ClearItem(SDRATTR_3DSCENE_DISTANCE);
+ aSet.ClearItem(SDRATTR_3DSCENE_FOCAL_LENGTH);
+ aSet.ClearItem(SDRATTR_3DOBJ_DEPTH);
+ }
+
+ // Attribute zuweisen
+ GetView()->Set3DAttributes( aSet );
+
+ // Ende UNDO
+ GetView()->EndUndo();
+ }
+ else
+ {
+ InfoBox aInfoBox (
+ GetActiveWindow(),
+ String(SdResId(STR_ACTION_NOTPOSSIBLE)));
+ aInfoBox.Execute();
+ }
+
+ // Focus zurueckholen
+ GetActiveWindow()->GrabFocus();
+ }
+ }
+}
+
+}
diff --git a/sd/source/ui/view/drviewsj.cxx b/sd/source/ui/view/drviewsj.cxx
new file mode 100755
index 000000000000..70f0ecadc301
--- /dev/null
+++ b/sd/source/ui/view/drviewsj.cxx
@@ -0,0 +1,564 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include <com/sun/star/embed/EmbedMisc.hpp>
+#include <svl/aeitem.hxx>
+#ifndef _SVXIDS_HRC //autogen
+#include <svx/svxids.hrc>
+#endif
+#ifndef _GLOBL3D_HXX //autogen
+#include <svx/globl3d.hxx>
+#endif
+#include <editeng/eeitem.hxx>
+#ifndef _FLDITEM_HXX
+#include <editeng/flditem.hxx>
+#endif
+#include <svx/svdogrp.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/sxelditm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <svx/svdopath.hxx>
+#include <svx/polysc3d.hxx>
+#include <svx/obj3d.hxx>
+#include <sfx2/event.hxx>
+#include <sfx2/docfile.hxx>
+#include <rtl/ustrbuf.hxx>
+
+
+#include "app.hrc"
+
+#include "Outliner.hxx"
+#include "sdpage.hxx"
+#include "fupoor.hxx"
+#include "fusel.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "drawview.hxx"
+#include "optsitem.hxx"
+
+using namespace com::sun::star;
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Status (Enabled/Disabled) von Menue-SfxSlots setzen
+|*
+\************************************************************************/
+
+void DrawViewShell::GetMenuStateSel( SfxItemSet &rSet )
+{
+ // Status der Menueintraege, bzw. Buttons
+ // Einfachselektion
+
+ const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
+ sal_uLong nMarkCount = rMarkList.GetMarkCount();
+
+ if ( nMarkCount == 1 )
+ {
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_BEZIER_EDIT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_UNGROUP ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ENTER_GROUP ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_NAME_GROUP ) ||
+
+ // #i68101#
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_TITLE_DESCRIPTION ) ||
+
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_FILL_STYLE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CHANGEBEZIER ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CHANGEPOLYGON ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_LINEEND_POLYGON ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( OBJ_TITLETEXT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( OBJ_OUTLINETEXT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MEASURE_DLG ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONNECTION_DLG ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONNECTION_NEW_ROUTING ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_3D_LATHE ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_3D_LATHE_FAST ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_SHEAR ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_1BIT_THRESHOLD ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_1BIT_MATRIX ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_4BIT_GRAYS ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_4BIT_COLORS ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_8BIT_GRAYS ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_8BIT_COLORS ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_24BIT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_LEFT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_CENTER ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_RIGHT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_UP ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_MIDDLE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_DOWN ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_FRAME_TO_TOP ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MOREFRONT ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MOREBACK ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_FRAME_TO_BOTTOM ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_BEFORE_OBJ ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_BEHIND_OBJ ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_REVERSE_ORDER ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ORIGINAL_SIZE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SAVEGRAPHIC ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_TEXTATTR_DLG ) )
+ {
+ const SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ sal_uInt32 nInv = pObj->GetObjInventor();
+ sal_uInt16 nId = pObj->GetObjIdentifier();
+ SdrObjTransformInfoRec aInfoRec;
+ pObj->TakeObjInfo( aInfoRec );
+
+
+ // #91929#; don't show original size entry if not possible
+ if ( pObj->ISA( SdrOle2Obj ) )
+ {
+ SdrOle2Obj* pOleObj = PTR_CAST(SdrOle2Obj, pObj);
+ if (pOleObj->GetObjRef().is() &&
+ ((pOleObj->GetObjRef()->getStatus( pOleObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) ) )
+ rSet.DisableItem(SID_ORIGINAL_SIZE);
+ }
+
+ if ( !( pObj->ISA( SdrGrafObj ) ) )
+ {
+ rSet.DisableItem(SID_SAVEGRAPHIC);
+ }
+
+ // Wenn es sich um kein Gruppenobjekt oder 3D-Objekt handelt
+ // wird "Gruppe betreten" disabled
+ if( !( ( pObj->ISA( SdrObjGroup ) && nInv == SdrInventor ) ||
+ (pObj->ISA (E3dPolyScene) || pObj->ISA (E3dScene) /*|| pObj->ISA (E3dCompoundObject) */) ) )
+ {
+ rSet.DisableItem( SID_ENTER_GROUP );
+ }
+
+ // Wenn es sich um kein Gruppenobjekt handelt
+ // wird "Gruppierung aufheben" disabled
+ if (!(pObj->ISA(SdrObjGroup) && nInv == SdrInventor))
+ {
+ rSet.DisableItem(SID_UNGROUP);
+ }
+/*
+ if (!pObj->ISA(SdrObjGroup) && !pObj->ISA(SdrGrafObj) && !pObj->ISA(SdrOle2Obj))
+ {
+ rSet.DisableItem( SID_NAME_GROUP );
+ }
+*/
+ if (!pObj->ISA(SdrGrafObj) ||
+ ((SdrGrafObj*) pObj)->GetGraphicType() != GRAPHIC_BITMAP ||
+ ((SdrGrafObj*) pObj)->IsLinkedGraphic())
+ {
+ rSet.DisableItem(SID_CONVERT_TO_1BIT_THRESHOLD);
+ rSet.DisableItem(SID_CONVERT_TO_1BIT_MATRIX);
+ rSet.DisableItem(SID_CONVERT_TO_4BIT_GRAYS);
+ rSet.DisableItem(SID_CONVERT_TO_4BIT_COLORS);
+ rSet.DisableItem(SID_CONVERT_TO_8BIT_GRAYS);
+ rSet.DisableItem(SID_CONVERT_TO_8BIT_COLORS);
+ rSet.DisableItem(SID_CONVERT_TO_24BIT);
+ }
+
+ if( nInv == SdrInventor &&
+ (nId == OBJ_LINE ||
+ nId == OBJ_PLIN ||
+ nId == OBJ_PATHLINE ||
+ nId == OBJ_FREELINE ))
+ {
+ //rSet.DisableItem( SID_ATTRIBUTES_AREA ); // wieder raus!
+ rSet.DisableItem( SID_ATTR_FILL_STYLE );
+ }
+ if( (!pObj->ISA( SdrPathObj ) && !aInfoRec.bCanConvToPath) || pObj->ISA( SdrObjGroup ) ) // Solange es JOE fehlerhaft behandelt!
+ { // JOE: Ein Gruppenobjekt kann eben u.U. in ein PathObj gewandelt werden
+ rSet.DisableItem( SID_LINEEND_POLYGON );
+ }
+ if(nInv == SdrInventor &&
+ (nId == OBJ_PATHFILL || nId == OBJ_PATHLINE || !aInfoRec.bCanConvToPath))
+ rSet.DisableItem( SID_CHANGEBEZIER );
+
+ if( nInv == SdrInventor &&
+ ( nId == OBJ_POLY || nId == OBJ_PLIN || !aInfoRec.bCanConvToPoly ) &&
+ !GetView()->IsVectorizeAllowed() )
+ {
+ rSet.DisableItem( SID_CHANGEPOLYGON );
+ }
+
+ if(nInv == SdrInventor && (nId == OBJ_TITLETEXT || nId == OBJ_OUTLINETEXT))
+ rSet.DisableItem( SID_TEXTATTR_DLG );
+
+ if(nInv == SdrInventor && nId == OBJ_TABLE )
+ {
+ rSet.DisableItem( SID_TEXTATTR_DLG );
+ }
+
+ if( nInv != SdrInventor || nId != OBJ_MEASURE )
+ rSet.DisableItem( SID_MEASURE_DLG );
+
+ if( nInv != SdrInventor || nId != OBJ_EDGE )
+ rSet.DisableItem( SID_CONNECTION_DLG );
+ else
+ {
+ sal_Bool bDisable = sal_True;
+ SfxItemSet aAttrSet( GetDoc()->GetPool() );
+ GetView()->GetAttributes( aAttrSet );
+
+ if( aAttrSet.GetItemState( SDRATTR_EDGELINE1DELTA ) >= SFX_ITEM_AVAILABLE &&
+ aAttrSet.GetItemState( SDRATTR_EDGELINE2DELTA ) >= SFX_ITEM_AVAILABLE &&
+ aAttrSet.GetItemState( SDRATTR_EDGELINE3DELTA ) >= SFX_ITEM_AVAILABLE )
+ {
+ long nVal1 = ( ( const SdrEdgeLine1DeltaItem& ) aAttrSet.Get( SDRATTR_EDGELINE1DELTA ) ).GetValue();
+ long nVal2 = ( ( const SdrEdgeLine2DeltaItem& ) aAttrSet.Get( SDRATTR_EDGELINE2DELTA ) ).GetValue();
+ long nVal3 = ( ( const SdrEdgeLine3DeltaItem& ) aAttrSet.Get( SDRATTR_EDGELINE3DELTA ) ).GetValue();
+ {
+ if( nVal1 != 0 || nVal2 != 0 || nVal3 != 0 )
+ bDisable = sal_False;
+ }
+ }
+ if( bDisable )
+ rSet.DisableItem( SID_CONNECTION_NEW_ROUTING );
+ }
+
+ if ( nInv == E3dInventor ||
+ (!mpDrawView->IsConvertToPathObjPossible(sal_False) &&
+ !mpDrawView->IsShearAllowed() &&
+ !mpDrawView->IsDistortAllowed()) )
+ {
+ rSet.DisableItem( SID_OBJECT_SHEAR );
+ }
+
+ if(pObj->ISA(E3dCompoundObject))
+ {
+ rSet.DisableItem( SID_OBJECT_ALIGN_LEFT );
+ rSet.DisableItem( SID_OBJECT_ALIGN_CENTER );
+ rSet.DisableItem( SID_OBJECT_ALIGN_RIGHT );
+ rSet.DisableItem( SID_OBJECT_ALIGN_UP );
+ rSet.DisableItem( SID_OBJECT_ALIGN_MIDDLE );
+ rSet.DisableItem( SID_OBJECT_ALIGN_DOWN );
+ rSet.DisableItem( SID_FRAME_TO_TOP );
+ rSet.DisableItem( SID_MOREFRONT );
+ rSet.DisableItem( SID_MOREBACK );
+ rSet.DisableItem( SID_FRAME_TO_BOTTOM );
+ rSet.DisableItem( SID_BEFORE_OBJ );
+ rSet.DisableItem( SID_BEHIND_OBJ );
+ rSet.DisableItem( SID_REVERSE_ORDER );
+ }
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_DISMANTLE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_BREAK ) )
+ {
+ if ( !mpDrawView->IsDismantlePossible(sal_False) )
+ {
+ rSet.DisableItem( SID_DISMANTLE );
+ }
+
+ if ( !mpDrawView->IsDismantlePossible(sal_True) &&
+ !mpDrawView->IsImportMtfPossible() &&
+ !mpDrawView->IsBreak3DObjPossible() )
+ {
+ rSet.DisableItem( SID_BREAK );
+ }
+ }
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MODIFY_FIELD ) )
+ {
+ OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
+
+ if( pOLV )
+ {
+ const SvxFieldItem* pFldItem = pOLV->GetFieldAtSelection();
+
+ if( !( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
+ pFldItem->GetField()->ISA( SvxAuthorField ) ||
+ pFldItem->GetField()->ISA( SvxExtFileField ) ||
+ pFldItem->GetField()->ISA( SvxExtTimeField ) ) ) )
+ {
+ rSet.DisableItem( SID_MODIFY_FIELD );
+ }
+ }
+ else
+ rSet.DisableItem( SID_MODIFY_FIELD );
+ }
+
+ rSet.DisableItem( SID_GROUP );
+ rSet.DisableItem( SID_COMBINE );
+ rSet.DisableItem(SID_DISTRIBUTE_DLG);
+ rSet.DisableItem(SID_POLY_MERGE);
+ rSet.DisableItem(SID_POLY_SUBSTRACT);
+ rSet.DisableItem(SID_POLY_INTERSECT);
+ rSet.DisableItem( SID_CONNECT );
+ }
+ // Mehrfachselektion
+ else if( nMarkCount > 1 )
+ {
+ // distribure dialog for 3+n objects
+ if(nMarkCount <= 2)
+ rSet.DisableItem(SID_DISTRIBUTE_DLG);
+
+// rSet.ClearItem( SID_BEZIER_EDIT );
+// rSet.DisableItem( SID_BEZIER_EDIT );
+ rSet.DisableItem( SID_LINEEND_POLYGON );
+ rSet.DisableItem( SID_ENTER_GROUP );
+ // Jetzt (28.10.96) muessen Namen fuer Objekte eindeutig sein
+ rSet.DisableItem( SID_NAME_GROUP );
+ // #i68101#
+ rSet.DisableItem( SID_OBJECT_TITLE_DESCRIPTION );
+ rSet.DisableItem( SID_MODIFY_FIELD );
+
+ if( 1 )
+// if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_FILL_STYLE ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_UNGROUP ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MEASURE_DLG ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONNECTION_DLG ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_COMBINE ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_SHEAR ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_TEXTATTR_DLG ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_3D_LATHE ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_CONVERT_TO_3D_LATHE_FAST ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_LEFT ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_CENTER ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_RIGHT ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_UP ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_MIDDLE ) ||
+// SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_OBJECT_ALIGN_DOWN ) )
+ {
+ sal_Bool bText = sal_False;
+ sal_Bool bLine = sal_False;
+ sal_Bool bGroup = sal_False;
+ sal_Bool bGraf = sal_False;
+ sal_Bool bDrawObj = sal_False;
+ sal_Bool b3dObj = sal_False;
+ sal_Bool bTitOutText = sal_False;
+ bool bTable = false;
+ sal_Bool bMeasureObj = sal_False;
+ sal_Bool bEdgeObj = sal_False; // Connector
+ sal_Bool bE3dCompoundObject = sal_False;
+
+ for( sal_uLong i = 0;
+ i < nMarkCount && !bText && i < 50;
+ i++ )
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ sal_uInt32 nInv = pObj->GetObjInventor();
+ sal_uInt16 nId = pObj->GetObjIdentifier();
+
+ if (nInv == SdrInventor)
+ {
+ switch (nId)
+ {
+ case OBJ_TEXT: bText = sal_True; break;
+
+ case OBJ_LINE: bLine = sal_True; break;
+
+ case OBJ_EDGE: bEdgeObj = sal_True; break;
+
+ case OBJ_MEASURE: bMeasureObj = sal_True; break;
+
+ case OBJ_RECT:
+ case OBJ_CIRC:
+ case OBJ_FREELINE:
+ case OBJ_FREEFILL:
+ case OBJ_PATHFILL:
+ case OBJ_PATHLINE:
+ case OBJ_SECT:
+ case OBJ_CARC:
+ case OBJ_CCUT: bDrawObj = sal_True; break;
+
+ case OBJ_GRUP: bGroup = sal_True; break;
+
+ case OBJ_GRAF: bGraf = sal_True; break;
+
+ case OBJ_TITLETEXT:
+ case OBJ_OUTLINETEXT: bTitOutText = sal_True; break;
+ case OBJ_TABLE: bTable = true; break;
+ }
+ }
+ else if (nInv == E3dInventor)
+ {
+ if(pObj->ISA(E3dScene))
+ b3dObj = sal_True;
+ else if(pObj->ISA(E3dCompoundObject))
+ bE3dCompoundObject = sal_True;
+ }
+ }
+ /* Kann wohl raus, da jedes(?) Objekt Text enthalten kann
+ if( !bText )
+ {
+ rSet.DisableItem( SID_CHAR_DLG );
+ rSet.DisableItem( SID_PARA_DLG );
+ rSet.DisableItem( SID_CHARMAP );
+ }
+ */
+ if( bLine && !bText && !bDrawObj &&!b3dObj)
+ {
+ //rSet.DisableItem( SID_ATTRIBUTES_AREA );
+ rSet.DisableItem( SID_ATTR_FILL_STYLE );
+ }
+ if( !bEdgeObj )
+ rSet.DisableItem( SID_CONNECTION_DLG );
+
+ if (b3dObj)
+ {
+ rSet.DisableItem( SID_COMBINE );
+ rSet.DisableItem(SID_POLY_MERGE);
+ rSet.DisableItem(SID_POLY_SUBSTRACT);
+ rSet.DisableItem(SID_POLY_INTERSECT);
+ }
+
+ if (b3dObj ||
+ (!mpDrawView->IsConvertToPathObjPossible(sal_False) &&
+ !mpDrawView->IsShearAllowed() &&
+ !mpDrawView->IsDistortAllowed()) )
+ {
+ rSet.DisableItem( SID_OBJECT_SHEAR );
+ }
+
+ if( !bGroup )
+ {
+ rSet.DisableItem( SID_UNGROUP );
+ }
+ if( bTitOutText || bTable )
+ rSet.DisableItem( SID_TEXTATTR_DLG );
+
+ if( !bMeasureObj )
+ rSet.DisableItem( SID_MEASURE_DLG );
+
+ if (!bGraf)
+ {
+ rSet.DisableItem(SID_CONVERT_TO_1BIT_THRESHOLD);
+ rSet.DisableItem(SID_CONVERT_TO_1BIT_MATRIX);
+ rSet.DisableItem(SID_CONVERT_TO_4BIT_GRAYS);
+ rSet.DisableItem(SID_CONVERT_TO_4BIT_COLORS);
+ rSet.DisableItem(SID_CONVERT_TO_8BIT_GRAYS);
+ rSet.DisableItem(SID_CONVERT_TO_8BIT_COLORS);
+ rSet.DisableItem(SID_CONVERT_TO_24BIT);
+ }
+
+ if(bE3dCompoundObject)
+ {
+ rSet.DisableItem( SID_OBJECT_ALIGN_LEFT );
+ rSet.DisableItem( SID_OBJECT_ALIGN_CENTER );
+ rSet.DisableItem( SID_OBJECT_ALIGN_RIGHT );
+ rSet.DisableItem( SID_OBJECT_ALIGN_UP );
+ rSet.DisableItem( SID_OBJECT_ALIGN_MIDDLE );
+ rSet.DisableItem( SID_OBJECT_ALIGN_DOWN );
+ rSet.DisableItem( SID_FRAME_TO_TOP );
+ rSet.DisableItem( SID_MOREFRONT );
+ rSet.DisableItem( SID_MOREBACK );
+ rSet.DisableItem( SID_FRAME_TO_BOTTOM );
+ rSet.DisableItem( SID_BEFORE_OBJ );
+ rSet.DisableItem( SID_BEHIND_OBJ );
+ rSet.DisableItem( SID_REVERSE_ORDER );
+ }
+ }
+
+ if ( !mpDrawView->IsDismantlePossible(sal_False) )
+ {
+ rSet.DisableItem( SID_DISMANTLE );
+ }
+ if ( !mpDrawView->IsDismantlePossible(sal_True) &&
+ !mpDrawView->IsImportMtfPossible() &&
+ !mpDrawView->IsBreak3DObjPossible() )
+ {
+ rSet.DisableItem( SID_BREAK );
+ }
+ if ( !mpDrawView->IsCombinePossible(sal_False) )
+ {
+ rSet.DisableItem( SID_COMBINE );
+ rSet.DisableItem(SID_POLY_MERGE);
+ rSet.DisableItem(SID_POLY_SUBSTRACT);
+ rSet.DisableItem(SID_POLY_INTERSECT);
+ }
+ if ( !mpDrawView->IsCombinePossible(sal_True) )
+ {
+ rSet.DisableItem( SID_CONNECT );
+ }
+ if ( !mpDrawView->IsGroupPossible() )
+ {
+ rSet.DisableItem( SID_GROUP );
+ }
+ if ( !mpDrawView->IsUnGroupPossible() )
+ {
+ rSet.DisableItem( SID_UNGROUP );
+ }
+ }
+ // kein Objekt selektiert
+ else
+ {
+// rSet.ClearItem( SID_BEZIER_EDIT );
+
+ rSet.DisableItem( SID_ENTER_GROUP );
+ rSet.DisableItem( SID_CUT );
+ rSet.DisableItem( SID_COPY );
+ rSet.DisableItem( SID_DELETE );
+ rSet.DisableItem( SID_ATTR_TRANSFORM );
+
+ rSet.DisableItem( SID_OBJECT_ALIGN_LEFT );
+ rSet.DisableItem( SID_OBJECT_ALIGN_CENTER );
+ rSet.DisableItem( SID_OBJECT_ALIGN_RIGHT );
+ rSet.DisableItem( SID_OBJECT_ALIGN_UP );
+ rSet.DisableItem( SID_OBJECT_ALIGN_MIDDLE );
+ rSet.DisableItem( SID_OBJECT_ALIGN_DOWN );
+
+ rSet.DisableItem( SID_FRAME_TO_TOP );
+ rSet.DisableItem( SID_MOREFRONT );
+ rSet.DisableItem( SID_MOREBACK );
+ rSet.DisableItem( SID_FRAME_TO_BOTTOM );
+ rSet.DisableItem( SID_BEFORE_OBJ );
+ rSet.DisableItem( SID_BEHIND_OBJ );
+ rSet.DisableItem( SID_CONVERT );
+
+// rSet.DisableItem( SID_BEZIER_EDIT );
+ rSet.DisableItem( SID_SIZE_OPTIMAL );
+ rSet.DisableItem( SID_LINEEND_POLYGON );
+ rSet.DisableItem( SID_COPYOBJECTS );
+ rSet.DisableItem( SID_HORIZONTAL );
+ rSet.DisableItem( SID_VERTICAL );
+ rSet.DisableItem( SID_GROUP );
+ rSet.DisableItem( SID_UNGROUP );
+ rSet.DisableItem( SID_NAME_GROUP );
+
+ // #i68101#
+ rSet.DisableItem( SID_OBJECT_TITLE_DESCRIPTION );
+
+ rSet.DisableItem( SID_DISMANTLE );
+ rSet.DisableItem( SID_BREAK );
+ rSet.DisableItem( SID_COMBINE );
+ rSet.DisableItem(SID_DISTRIBUTE_DLG);
+ rSet.DisableItem(SID_POLY_MERGE);
+ rSet.DisableItem(SID_POLY_SUBSTRACT);
+ rSet.DisableItem(SID_POLY_INTERSECT);
+ rSet.DisableItem( SID_CONNECT );
+ rSet.DisableItem( SID_ANIMATION_EFFECTS );
+ rSet.DisableItem( SID_MODIFY_FIELD );
+ rSet.DisableItem (SID_OBJECT_SHEAR);
+ }
+
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/drvwshrg.cxx b/sd/source/ui/view/drvwshrg.cxx
new file mode 100755
index 000000000000..76590dd45003
--- /dev/null
+++ b/sd/source/ui/view/drvwshrg.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * 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 "DrawViewShell.hxx"
+#include <sfx2/templdlg.hxx>
+
+#include <svx/fontwork.hxx>
+#include <svx/bmpmask.hxx>
+#include <svx/galbrws.hxx>
+#include <svx/imapdlg.hxx>
+#include <svx/colrctrl.hxx>
+#include <sfx2/objface.hxx>
+#include <svx/f3dchild.hxx>
+#include <svx/tbxcustomshapes.hxx>
+
+#include <svx/svxids.hrc>
+#include <svx/hyprlink.hxx>
+#include <svx/hyperdlg.hxx>
+#include <avmedia/mediaplayer.hxx>
+
+
+#include "app.hrc"
+#include "strings.hrc"
+#include "res_bmp.hrc"
+#include "glob.hrc"
+#include "SpellDialogChildWindow.hxx"
+#include "sdresid.hxx"
+#include "DrawDocShell.hxx"
+#include "GraphicDocShell.hxx"
+#include "GraphicViewShell.hxx"
+#include "AnimationChildWindow.hxx"
+#include "NavigatorChildWindow.hxx"
+#include "LayerDialogChildWindow.hxx"
+
+using namespace sd;
+#define DrawViewShell
+#include "sdslots.hxx"
+#define GraphicViewShell
+#include "sdgslots.hxx"
+
+namespace sd {
+
+//AF:unused #define TABCONTROL_INITIAL_SIZE 500
+
+/*************************************************************************
+|*
+|* SFX-Slotmap und Standardinterface deklarieren
+|*
+\************************************************************************/
+
+
+SFX_IMPL_INTERFACE(DrawViewShell, SfxShell, SdResId(STR_DRAWVIEWSHELL))
+{
+ SFX_POPUPMENU_REGISTRATION( SdResId(RID_DRAW_TEXTOBJ_INSIDE_POPUP) );
+ SFX_CHILDWINDOW_CONTEXT_REGISTRATION( SID_NAVIGATOR );
+ SFX_CHILDWINDOW_REGISTRATION( SfxTemplateDialogWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxFontWorkChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxColorChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( AnimationChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( Svx3DChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxBmpMaskChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( GalleryChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxIMapDlgChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxHyperlinkDlgWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxHlinkDlgWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( ::sd::SpellDialogChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SID_SEARCH_DLG );
+ SFX_CHILDWINDOW_REGISTRATION( ::avmedia::MediaPlayer::GetChildWindowId() );
+}
+
+
+TYPEINIT1( DrawViewShell, ViewShell );
+
+
+// SdGraphicViewShell
+
+
+SFX_IMPL_INTERFACE(GraphicViewShell, SfxShell, SdResId(STR_DRAWVIEWSHELL)) //SOH...
+{
+ SFX_POPUPMENU_REGISTRATION( SdResId(RID_DRAW_TEXTOBJ_INSIDE_POPUP) );
+ SFX_CHILDWINDOW_CONTEXT_REGISTRATION( SID_NAVIGATOR );
+ SFX_CHILDWINDOW_REGISTRATION( SID_TASKPANE );
+ SFX_CHILDWINDOW_REGISTRATION( SfxTemplateDialogWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxFontWorkChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxColorChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( Svx3DChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxBmpMaskChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( GalleryChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxIMapDlgChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxHyperlinkDlgWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxHlinkDlgWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( ::sd::SpellDialogChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SID_SEARCH_DLG );
+ SFX_CHILDWINDOW_REGISTRATION( ::avmedia::MediaPlayer::GetChildWindowId() );
+}
+
+TYPEINIT1( GraphicViewShell, DrawViewShell );
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/frmview.cxx b/sd/source/ui/view/frmview.cxx
new file mode 100755
index 000000000000..3f77658d5021
--- /dev/null
+++ b/sd/source/ui/view/frmview.cxx
@@ -0,0 +1,1214 @@
+/*************************************************************************
+ *
+ * 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 "FrameView.hxx"
+
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/drawing/framework/ResourceId.hpp>
+#include <rtl/ustrbuf.hxx>
+#include "unokywds.hxx"
+
+#include <vector>
+#include "ViewShell.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "optsitem.hxx"
+#include "ViewShellBase.hxx"
+#include "DrawViewShell.hxx"
+#include "OutlineViewShell.hxx"
+#include "app.hxx"
+#include "sdresid.hxx"
+#include "pres.hxx"
+#include "glob.hrc"
+#include "sdiocmpt.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include <comphelper/processfactory.hxx>
+#include <sfx2/viewfrm.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::std;
+using ::rtl::OUString;
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+FrameView::FrameView(SdDrawDocument* pDrawDoc, FrameView* pFrameView /* = NULK */)
+ : SdrView(pDrawDoc, (OutputDevice*) NULL),
+ mnRefCount(0),
+ mnPresViewShellId(SID_VIEWSHELL0),
+ mnSlotId(SID_OBJECT_SELECT),
+ mbIsNavigatorShowingAllShapes(false)
+{
+ EndListening(*pDrawDoc);
+
+ EnableExtendedKeyInputDispatcher(sal_False);
+ EnableExtendedMouseEventDispatcher(sal_False);
+ EnableExtendedCommandEventDispatcher(sal_False);
+
+ SetGridFront( sal_False );
+ SetHlplFront( sal_False );
+ SetOConSnap( sal_False );
+ SetFrameDragSingles( sal_True );
+ SetSlidesPerRow(4);
+
+ if( NULL == pFrameView )
+ {
+ DrawDocShell* pDocShell = pDrawDoc->GetDocSh();
+
+ if ( pDocShell )
+ {
+ /**********************************************************************
+ * Das Dokument wurde geladen, ist eine FrameView vorhanden?
+ **********************************************************************/
+ sal_uLong nSdViewShellCount = 0;
+ ViewShellBase* pBase = NULL;
+ SfxViewShell* pSfxViewSh = NULL;
+ SfxViewFrame* pSfxViewFrame = SfxViewFrame::GetFirst(pDocShell);
+
+ while (pSfxViewFrame)
+ {
+ // Count the FrameViews and remember the type of the main
+ // view shell.
+ pSfxViewSh = pSfxViewFrame->GetViewShell();
+ pBase = PTR_CAST(ViewShellBase, pSfxViewSh );
+
+ if (pBase != NULL)
+ {
+ nSdViewShellCount++;
+
+ ::rtl::OUString sViewURL;
+ Reference<drawing::framework::XView> xView (
+ framework::FrameworkHelper::Instance(*pBase)->GetView(
+ drawing::framework::ResourceId::create(
+ ::comphelper::getProcessComponentContext(),
+ framework::FrameworkHelper::msCenterPaneURL)));
+ if (xView.is())
+ sViewURL = xView->getResourceId()->getResourceURL();
+
+ switch (framework::FrameworkHelper::GetViewId(sViewURL))
+ {
+ default:
+// case ViewShell::ST_IMPRESS:
+// case ViewShell::ST_NOTES:
+// case ViewShell::ST_HANDOUT:
+ mnPresViewShellId = SID_VIEWSHELL0;
+ break;
+
+ case ViewShell::ST_SLIDE_SORTER:
+ mnPresViewShellId = SID_VIEWSHELL1;
+ break;
+
+ case ViewShell::ST_OUTLINE:
+ mnPresViewShellId = SID_VIEWSHELL2;
+ break;
+ }
+ }
+
+ pSfxViewFrame = SfxViewFrame::GetNext(*pSfxViewFrame, pDocShell);
+ }
+
+ SdDrawDocument* pDoc = pDocShell->GetDoc();
+ pFrameView = pDoc->GetFrameView(nSdViewShellCount);
+ }
+ }
+
+ if (pFrameView)
+ {
+ /**********************************************************************
+ * FrameView mit der FrameView der DocShell initialisieren
+ **********************************************************************/
+ SetRuler( pFrameView->HasRuler() );
+ SetGridCoarse( pFrameView->GetGridCoarse() );
+ SetGridFine( pFrameView->GetGridFine() );
+ SetSnapGridWidth(pFrameView->GetSnapGridWidthX(), pFrameView->GetSnapGridWidthY());
+ SetGridVisible( pFrameView->IsGridVisible() );
+ SetGridFront( pFrameView->IsGridFront() );
+ SetSnapAngle( pFrameView->GetSnapAngle() );
+ SetGridSnap( pFrameView->IsGridSnap() );
+ SetBordSnap( pFrameView->IsBordSnap() );
+ SetHlplSnap( pFrameView->IsHlplSnap() );
+ SetOFrmSnap( pFrameView->IsOFrmSnap() );
+ SetOPntSnap( pFrameView->IsOPntSnap() );
+ SetOConSnap( pFrameView->IsOConSnap() );
+ SetHlplVisible( pFrameView->IsHlplVisible() );
+ SetDragStripes( pFrameView->IsDragStripes() );
+ SetPlusHandlesAlwaysVisible( pFrameView->IsPlusHandlesAlwaysVisible() );
+ SetFrameDragSingles( pFrameView->IsFrameDragSingles() );
+ SetSnapMagneticPixel( pFrameView->GetSnapMagneticPixel() );
+ SetMarkedHitMovesAlways( pFrameView->IsMarkedHitMovesAlways() );
+ SetMoveOnlyDragging( pFrameView->IsMoveOnlyDragging() );
+ SetCrookNoContortion( pFrameView->IsCrookNoContortion() );
+ SetSlantButShear( pFrameView->IsSlantButShear() );
+ SetNoDragXorPolys( pFrameView->IsNoDragXorPolys() );
+ SetAngleSnapEnabled( pFrameView->IsAngleSnapEnabled() );
+ SetBigOrtho( pFrameView->IsBigOrtho() );
+ SetOrtho( pFrameView->IsOrtho() );
+ SetEliminatePolyPointLimitAngle( pFrameView->GetEliminatePolyPointLimitAngle() );
+ SetEliminatePolyPoints( pFrameView->IsEliminatePolyPoints() );
+// #110094#-7
+// SetMasterPagePaintCaching( pFrameView->IsMasterPagePaintCaching() );
+ SetDesignMode( pFrameView->IsDesignMode() );
+
+ SetSolidMarkHdl( pFrameView->IsSolidMarkHdl() );
+ SetSolidDragging( pFrameView->IsSolidDragging() );
+
+ maVisibleLayers = pFrameView->GetVisibleLayers();
+ maPrintableLayers = pFrameView->GetPrintableLayers();
+ maLockedLayers = pFrameView->GetLockedLayers();
+ maStandardHelpLines = pFrameView->GetStandardHelpLines();
+ maNotesHelpLines = pFrameView->GetNotesHelpLines();
+ maHandoutHelpLines = pFrameView->GetHandoutHelpLines();
+ SetActiveLayer( pFrameView->GetActiveLayer() );
+ mbNoColors = pFrameView->IsNoColors();
+ mbNoAttribs = pFrameView->IsNoAttribs() ;
+ maVisArea = pFrameView->GetVisArea();
+ mePageKind = pFrameView->GetPageKind();
+ mePageKindOnLoad = pFrameView->GetPageKindOnLoad();
+ mnSelectedPage = pFrameView->GetSelectedPage();
+ mnSelectedPageOnLoad = pFrameView->GetSelectedPageOnLoad();
+ meStandardEditMode = pFrameView->GetViewShEditMode(PK_STANDARD);
+ meNotesEditMode = pFrameView->GetViewShEditMode(PK_NOTES);
+ meHandoutEditMode = pFrameView->GetViewShEditMode(PK_HANDOUT);
+ SetViewShEditModeOnLoad(pFrameView->GetViewShEditModeOnLoad());
+ mbLayerMode = pFrameView->IsLayerMode();
+ mbQuickEdit = pFrameView->IsQuickEdit();
+
+ // #i26631#
+ SetMasterPagePaintCaching( pFrameView->IsMasterPagePaintCaching() );
+
+ SetDragWithCopy( pFrameView->IsDragWithCopy() );
+ mbBigHandles = pFrameView->IsBigHandles();
+ mbDoubleClickTextEdit = pFrameView->IsDoubleClickTextEdit();
+ mbClickChangeRotation = pFrameView->IsClickChangeRotation();
+ mnSlidesPerRow = pFrameView->GetSlidesPerRow();
+ mnDrawMode = pFrameView->GetDrawMode();
+ mnTabCtrlPercent = pFrameView->GetTabCtrlPercent();
+ mbIsNavigatorShowingAllShapes = pFrameView->IsNavigatorShowingAllShapes();
+ SetPreviousViewShellType (pFrameView->GetPreviousViewShellType());
+ SetViewShellTypeOnLoad (pFrameView->GetViewShellTypeOnLoad());
+ }
+ else
+ {
+ /**********************************************************************
+ * FrameView mit den Applikationsdaten initialisieren
+ **********************************************************************/
+ maVisibleLayers.SetAll();
+ maPrintableLayers.SetAll();
+ SetGridCoarse( Size( 1000, 1000 ) );
+ SetSnapGridWidth(Fraction(1000, 1), Fraction(1000, 1));
+ SetActiveLayer( String( SdResId(STR_LAYER_LAYOUT) ) );
+ mbNoColors = sal_True;
+ mbNoAttribs = sal_False;
+ maVisArea = Rectangle( Point(), Size(0, 0) );
+ mePageKind = PK_STANDARD;
+ mePageKindOnLoad = PK_STANDARD;
+ mnSelectedPage = 0;
+ mnSelectedPageOnLoad = 0;
+ meStandardEditMode = EM_PAGE;
+ meNotesEditMode = EM_PAGE;
+ meHandoutEditMode = EM_MASTERPAGE;
+ SetViewShEditModeOnLoad(EM_PAGE);
+ mbLayerMode = sal_False;
+ SetEliminatePolyPoints(sal_False);
+ mbBigHandles = sal_False;
+ mbDoubleClickTextEdit = sal_False;
+ mbClickChangeRotation = sal_False;
+ mnSlidesPerRow = 4;
+
+ {
+ bool bUseContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+ mnDrawMode = bUseContrast ? OUTPUT_DRAWMODE_CONTRAST : OUTPUT_DRAWMODE_COLOR;
+ }
+ mnTabCtrlPercent = 0.0;
+ mbIsNavigatorShowingAllShapes = false;
+ SetPreviousViewShellType (ViewShell::ST_NONE);
+ SetViewShellTypeOnLoad (ViewShell::ST_IMPRESS);
+
+ // get default for design mode
+ sal_Bool bInitDesignMode = pDrawDoc->GetOpenInDesignMode();
+ if( pDrawDoc->OpenInDesignModeIsDefaulted() )
+ {
+ bInitDesignMode = sal_True;
+ }
+
+ SfxObjectShell* pObjShell = pDrawDoc->GetObjectShell();
+ if( pObjShell && pObjShell->IsReadOnly() )
+ bInitDesignMode = sal_False;
+ SetDesignMode( bInitDesignMode );
+
+ Update( SD_MOD()->GetSdOptions(pDrawDoc->GetDocumentType()) );
+ }
+
+}
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+
+FrameView::~FrameView()
+{
+}
+
+
+/*************************************************************************
+|*
+|* Verbindung herstellen
+|*
+\************************************************************************/
+
+void FrameView::Connect()
+{
+ mnRefCount++;
+}
+
+
+/*************************************************************************
+|*
+|* Verbindung loesen
+|*
+\************************************************************************/
+
+void FrameView::Disconnect()
+{
+ if (mnRefCount > 0)
+ {
+ mnRefCount--;
+ }
+
+ if (mnRefCount == 0)
+ {
+ delete this;
+ }
+}
+
+/*************************************************************************
+|*
+|* Update mit Daten der SdOptions
+|*
+\************************************************************************/
+
+void FrameView::Update(SdOptions* pOptions)
+{
+ if (pOptions)
+ {
+ mbRuler = pOptions->IsRulerVisible();
+ SetGridVisible( pOptions->IsGridVisible() );
+ SetSnapAngle( pOptions->GetAngle() );
+ SetGridSnap( pOptions->IsUseGridSnap() );
+ SetBordSnap( pOptions->IsSnapBorder() );
+ SetHlplSnap( pOptions->IsSnapHelplines() );
+ SetOFrmSnap( pOptions->IsSnapFrame() );
+ SetOPntSnap( pOptions->IsSnapPoints() );
+ SetHlplVisible( pOptions->IsHelplines() );
+ SetDragStripes( pOptions->IsDragStripes() );
+ SetPlusHandlesAlwaysVisible( pOptions->IsHandlesBezier() );
+ SetSnapMagneticPixel( pOptions->GetSnapArea() );
+ SetMarkedHitMovesAlways( pOptions->IsMarkedHitMovesAlways() );
+ SetMoveOnlyDragging( pOptions->IsMoveOnlyDragging() );
+ SetSlantButShear( pOptions->IsMoveOnlyDragging() );
+ SetNoDragXorPolys ( !pOptions->IsMoveOutline() );
+ SetCrookNoContortion( pOptions->IsCrookNoContortion() );
+ SetAngleSnapEnabled( pOptions->IsRotate() );
+ SetBigOrtho( pOptions->IsBigOrtho() );
+ SetOrtho( pOptions->IsOrtho() );
+ SetEliminatePolyPointLimitAngle( pOptions->GetEliminatePolyPointLimitAngle() );
+// #110094#-7
+// SetMasterPagePaintCaching( pOptions->IsMasterPagePaintCaching() );
+ GetModel()->SetPickThroughTransparentTextFrames( pOptions->IsPickThrough() );
+
+ SetSolidMarkHdl( pOptions->IsSolidMarkHdl() );
+ SetSolidDragging( pOptions->IsSolidDragging() );
+
+ SetGridCoarse( Size( pOptions->GetFldDrawX(), pOptions->GetFldDrawY() ) );
+ SetGridFine( Size( pOptions->GetFldDivisionX(), pOptions->GetFldDivisionY() ) );
+ Fraction aFractX(pOptions->GetFldDrawX(), pOptions->GetFldDrawX() / ( pOptions->GetFldDivisionX() ? pOptions->GetFldDivisionX() : 1 ));
+ Fraction aFractY(pOptions->GetFldDrawY(), pOptions->GetFldDrawY() / ( pOptions->GetFldDivisionY() ? pOptions->GetFldDivisionY() : 1 ));
+ SetSnapGridWidth(aFractX, aFractY);
+ SetQuickEdit(pOptions->IsQuickEdit());
+
+ // #i26631#
+ SetMasterPagePaintCaching( pOptions->IsMasterPagePaintCaching() );
+
+ SetDragWithCopy(pOptions->IsDragWithCopy());
+ SetBigHandles( pOptions->IsBigHandles() );
+ SetDoubleClickTextEdit( pOptions->IsDoubleClickTextEdit() );
+ SetClickChangeRotation( pOptions->IsClickChangeRotation() );
+ }
+}
+
+
+/*************************************************************************
+|*
+|* EditMode (Page oder MasterPage) des Arbeitsmodus setzen
+|*
+\************************************************************************/
+
+void FrameView::SetViewShEditMode(EditMode eMode, PageKind eKind)
+{
+ if (eKind == PK_STANDARD)
+ {
+ meStandardEditMode = eMode;
+ }
+ else if (eKind == PK_NOTES)
+ {
+ meNotesEditMode = eMode;
+ }
+ else if (eKind == PK_HANDOUT)
+ {
+ meHandoutEditMode = eMode;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* EditMode (Page oder MasterPage) des Arbeitsmodus zurueckgeben
+|*
+\************************************************************************/
+
+EditMode FrameView::GetViewShEditMode(PageKind eKind)
+{
+ EditMode eMode = EM_PAGE;
+
+ if (eKind == PK_STANDARD)
+ {
+ eMode = meStandardEditMode;
+ }
+ else if (eKind == PK_NOTES)
+ {
+ eMode = meNotesEditMode;
+ }
+ else if (eKind == PK_HANDOUT)
+ {
+ eMode = meHandoutEditMode;
+ }
+
+ return (eMode);
+}
+
+
+
+
+void FrameView::SetViewShEditModeOnLoad (EditMode eMode)
+{
+ meEditModeOnLoad = eMode;
+}
+
+
+
+
+EditMode FrameView::GetViewShEditModeOnLoad (void) const
+{
+ return meEditModeOnLoad;
+}
+
+
+
+
+static OUString createHelpLinesString( const SdrHelpLineList& rHelpLines )
+{
+ ::rtl::OUStringBuffer aLines;
+
+ const sal_uInt16 nCount = rHelpLines.GetCount();
+ for( sal_uInt16 nHlpLine = 0; nHlpLine < nCount; nHlpLine++ )
+ {
+ const SdrHelpLine& rHelpLine = rHelpLines[nHlpLine];
+ const Point& rPos = rHelpLine.GetPos();
+
+ switch( rHelpLine.GetKind() )
+ {
+ case SDRHELPLINE_POINT:
+ aLines.append( (sal_Unicode)'P' );
+ aLines.append( (sal_Int32)rPos.X() );
+ aLines.append( (sal_Unicode)',' );
+ aLines.append( (sal_Int32)rPos.Y() );
+ break;
+ case SDRHELPLINE_VERTICAL:
+ aLines.append( (sal_Unicode)'V' );
+ aLines.append( (sal_Int32)rPos.X() );
+ break;
+ case SDRHELPLINE_HORIZONTAL:
+ aLines.append( (sal_Unicode)'H' );
+ aLines.append( (sal_Int32)rPos.Y() );
+ break;
+ default:
+ DBG_ERROR( "Unsupported helpline Kind!" );
+ }
+ }
+
+ return aLines.makeStringAndClear();
+}
+
+#define addValue( n, v ) push_back( std::pair< OUString, Any >( OUString( RTL_CONSTASCII_USTRINGPARAM( n ) ), v ) )
+void FrameView::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rValues, sal_Bool )
+{
+ std::vector< std::pair< OUString, Any > > aUserData;
+
+ aUserData.addValue( sUNO_View_GridIsVisible, makeAny( (sal_Bool)IsGridVisible() ) );
+ aUserData.addValue( sUNO_View_GridIsFront, makeAny( (sal_Bool)IsGridFront() ) );
+ aUserData.addValue( sUNO_View_IsSnapToGrid, makeAny( (sal_Bool)IsGridSnap() ) );
+ aUserData.addValue( sUNO_View_IsSnapToPageMargins, makeAny( (sal_Bool)IsBordSnap() ) );
+ aUserData.addValue( sUNO_View_IsSnapToSnapLines, makeAny( (sal_Bool)IsHlplSnap() ) );
+ aUserData.addValue( sUNO_View_IsSnapToObjectFrame, makeAny( (sal_Bool)IsOFrmSnap() ) );
+ aUserData.addValue( sUNO_View_IsSnapToObjectPoints, makeAny( (sal_Bool)IsOPntSnap() ) );
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsSnapLinesVisible ) );
+// pValue->Value <<= (sal_Bool)IsHlplVisible();
+// pValue++;nIndex++;
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsDragStripes ) );
+// pValue->Value <<= (sal_Bool)IsDragStripes();
+// pValue++;nIndex++;
+
+ aUserData.addValue( sUNO_View_IsPlusHandlesAlwaysVisible, makeAny( (sal_Bool)IsPlusHandlesAlwaysVisible() ) );
+ aUserData.addValue( sUNO_View_IsFrameDragSingles, makeAny( (sal_Bool)IsFrameDragSingles() ) );
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsMarkedHitMovesAlways ) );
+// pValue->Value <<= (sal_Bool)IsMarkedHitMovesAlways();
+// pValue++;nIndex++;
+
+ aUserData.addValue( sUNO_View_EliminatePolyPointLimitAngle, makeAny( (sal_Int32)GetEliminatePolyPointLimitAngle() ) );
+ aUserData.addValue( sUNO_View_IsEliminatePolyPoints, makeAny( (sal_Bool)IsEliminatePolyPoints() ) );
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsLineDraft ) );
+// pValue->Value <<= (sal_Bool)IsLineDraft();
+// pValue++;nIndex++;
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsFillDraft ) );
+// pValue->Value <<= (sal_Bool)IsFillDraft();
+// pValue++;nIndex++;
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsTextDraft ) );
+// pValue->Value <<= (sal_Bool)IsTextDraft();
+// pValue++;nIndex++;
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsGrafDraft ) );
+// pValue->Value <<= (sal_Bool)IsGrafDraft();
+// pValue++;nIndex++;
+
+ Any aAny;
+ GetVisibleLayers().QueryValue( aAny );
+ aUserData.addValue( sUNO_View_VisibleLayers, aAny );
+
+ GetPrintableLayers().QueryValue( aAny );
+ aUserData.addValue( sUNO_View_PrintableLayers, aAny );
+
+ GetLockedLayers().QueryValue( aAny );
+ aUserData.addValue( sUNO_View_LockedLayers, aAny );
+
+ aUserData.addValue( sUNO_View_NoAttribs, makeAny( (sal_Bool)IsNoAttribs() ) );
+ aUserData.addValue( sUNO_View_NoColors, makeAny( (sal_Bool)IsNoColors() ) );
+
+ if( GetStandardHelpLines().GetCount() )
+ aUserData.addValue( sUNO_View_SnapLinesDrawing, makeAny( createHelpLinesString( GetStandardHelpLines() ) ) );
+
+ if( GetNotesHelpLines().GetCount() )
+ aUserData.addValue( sUNO_View_SnapLinesNotes, makeAny( createHelpLinesString( GetNotesHelpLines() ) ) );
+
+ if( GetHandoutHelpLines().GetCount() )
+ aUserData.addValue( sUNO_View_SnapLinesHandout, makeAny( createHelpLinesString( GetHandoutHelpLines() ) ) );
+
+ aUserData.addValue( sUNO_View_RulerIsVisible, makeAny( (sal_Bool)HasRuler() ) );
+ aUserData.addValue( sUNO_View_PageKind, makeAny( (sal_Int16)GetPageKind() ) );
+ aUserData.addValue( sUNO_View_SelectedPage, makeAny( (sal_Int16)GetSelectedPage() ) );
+ aUserData.addValue( sUNO_View_IsLayerMode, makeAny( (sal_Bool)IsLayerMode() ) );
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsQuickEdit ) );
+// pValue->Value <<= (sal_Bool)IsQuickEdit();
+// pValue++;nIndex++;
+
+ aUserData.addValue( sUNO_View_IsBigHandles, makeAny( (sal_Bool)IsBigHandles() ) );
+ aUserData.addValue( sUNO_View_IsDoubleClickTextEdit, makeAny( (sal_Bool)IsDoubleClickTextEdit() ) );
+ aUserData.addValue( sUNO_View_IsClickChangeRotation, makeAny( (sal_Bool)IsClickChangeRotation() ) );
+
+// pValue->Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_View_IsDragWithCopy ) );
+// pValue->Value <<= (sal_Bool)IsDragWithCopy();
+// pValue++;nIndex++;
+
+ aUserData.addValue( sUNO_View_SlidesPerRow, makeAny( (sal_Int16)GetSlidesPerRow() ) );
+/* #107128# Product managment decided to not make this persistent
+ aUserData.addValue( sUNO_View_DrawMode, makeAny( (sal_Int32)GetDrawMode() ) );
+ aUserData.addValue( sUNO_View_PreviewDrawMode, makeAny( (sal_Int32)GetPreviewDrawMode() ) );
+*/
+ aUserData.addValue( sUNO_View_EditModeStandard, makeAny( (sal_Int32)GetViewShEditMode( PK_STANDARD ) ) );
+ aUserData.addValue( sUNO_View_EditModeNotes, makeAny( (sal_Int32)GetViewShEditMode( PK_NOTES ) ) );
+ aUserData.addValue( sUNO_View_EditModeHandout, makeAny( (sal_Int32)GetViewShEditMode( PK_HANDOUT ) ) );
+
+ {
+ const Rectangle aVisArea = GetVisArea();
+
+ aUserData.addValue( sUNO_View_VisibleAreaTop, makeAny( (sal_Int32)aVisArea.Top() ) );
+ aUserData.addValue( sUNO_View_VisibleAreaLeft, makeAny( (sal_Int32)aVisArea.Left() ) );
+ aUserData.addValue( sUNO_View_VisibleAreaWidth, makeAny( (sal_Int32)aVisArea.GetWidth() ) );
+ aUserData.addValue( sUNO_View_VisibleAreaHeight, makeAny( (sal_Int32)aVisArea.GetHeight() ) );
+ }
+
+ aUserData.addValue( sUNO_View_GridCoarseWidth, makeAny( (sal_Int32)GetGridCoarse().Width() ) );
+ aUserData.addValue( sUNO_View_GridCoarseHeight, makeAny( (sal_Int32)GetGridCoarse().Height() ) );
+ aUserData.addValue( sUNO_View_GridFineWidth, makeAny( (sal_Int32)GetGridFine().Width() ) );
+ aUserData.addValue( sUNO_View_GridFineHeight, makeAny( (sal_Int32)GetGridFine().Height() ) );
+ aUserData.addValue( sUNO_View_GridSnapWidthXNumerator, makeAny( (sal_Int32)GetSnapGridWidthX().GetNumerator() ) );
+ aUserData.addValue( sUNO_View_GridSnapWidthXDenominator, makeAny( (sal_Int32)GetSnapGridWidthX().GetDenominator() ) );
+ aUserData.addValue( sUNO_View_GridSnapWidthYNumerator, makeAny( (sal_Int32)GetSnapGridWidthY().GetNumerator() ) );
+ aUserData.addValue( sUNO_View_GridSnapWidthYDenominator, makeAny( (sal_Int32)GetSnapGridWidthY().GetDenominator() ) );
+ aUserData.addValue( sUNO_View_IsAngleSnapEnabled, makeAny( (sal_Bool)IsAngleSnapEnabled() ) );
+ aUserData.addValue( sUNO_View_SnapAngle, makeAny( (sal_Int32)GetSnapAngle() ) );
+
+ const sal_Int32 nOldLength = rValues.getLength();
+ rValues.realloc( nOldLength + aUserData.size() );
+
+ PropertyValue* pValue = &(rValues.getArray()[nOldLength]);
+
+ std::vector< std::pair< OUString, Any > >::iterator aIter( aUserData.begin() );
+ for( ; aIter != aUserData.end(); aIter++, pValue++ )
+ {
+ pValue->Name = (*aIter).first;
+ pValue->Value = (*aIter).second;
+ }
+}
+#undef addValue
+
+static void createHelpLinesFromString( const rtl::OUString& rLines, SdrHelpLineList& rHelpLines )
+{
+ const sal_Unicode * pStr = rLines.getStr();
+ SdrHelpLine aNewHelpLine;
+ rtl::OUStringBuffer sBuffer;
+
+ while( *pStr )
+ {
+ Point aPoint;
+
+ switch( *pStr )
+ {
+ case (sal_Unicode)'P':
+ aNewHelpLine.SetKind( SDRHELPLINE_POINT );
+ break;
+ case (sal_Unicode)'V':
+ aNewHelpLine.SetKind( SDRHELPLINE_VERTICAL );
+ break;
+ case (sal_Unicode)'H':
+ aNewHelpLine.SetKind( SDRHELPLINE_HORIZONTAL );
+ break;
+ default:
+ DBG_ERROR( "syntax error in snap lines settings string" );
+ return;
+ }
+
+ pStr++;
+
+ while( (*pStr >= sal_Unicode('0') && *pStr <= sal_Unicode('9')) || (*pStr == '+') || (*pStr == '-') )
+ {
+ sBuffer.append( *pStr++ );
+ }
+
+ sal_Int32 nValue = sBuffer.makeStringAndClear().toInt32();
+
+ if( aNewHelpLine.GetKind() == SDRHELPLINE_HORIZONTAL )
+ {
+ aPoint.Y() = nValue;
+ }
+ else
+ {
+ aPoint.X() = nValue;
+
+ if( aNewHelpLine.GetKind() == SDRHELPLINE_POINT )
+ {
+ if( *pStr++ != ',' )
+ return;
+
+ while( (*pStr >= sal_Unicode('0') && *pStr <= sal_Unicode('9')) || (*pStr == '+') || (*pStr == '-') )
+ {
+ sBuffer.append( *pStr++ );
+ }
+
+ aPoint.Y() = sBuffer.makeStringAndClear().toInt32();
+
+ }
+ }
+
+ aNewHelpLine.SetPos( aPoint );
+ rHelpLines.Insert( aNewHelpLine );
+ }
+}
+
+void FrameView::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool )
+{
+ const sal_Int32 nLength = rSequence.getLength();
+ if (nLength)
+ {
+ const bool bImpress = dynamic_cast< SdDrawDocument* >(GetModel())->GetDocumentType() == DOCUMENT_TYPE_IMPRESS;
+
+ sal_Bool bBool = sal_False;
+ sal_Int32 nInt32 = 0;
+ sal_Int16 nInt16 = 0;
+ rtl::OUString aString;
+
+ sal_Int32 aSnapGridWidthXNum = GetSnapGridWidthX().GetNumerator();
+ sal_Int32 aSnapGridWidthXDom = GetSnapGridWidthX().GetDenominator();
+
+ sal_Int32 aSnapGridWidthYNum = GetSnapGridWidthY().GetNumerator();
+ sal_Int32 aSnapGridWidthYDom = GetSnapGridWidthY().GetDenominator();
+
+ EditMode eStandardEditMode;
+ EditMode eNotesEditMode;
+ EditMode eHandoutEditMode;
+
+ const com::sun::star::beans::PropertyValue *pValue = rSequence.getConstArray();
+ for (sal_Int16 i = 0 ; i < nLength; i++, pValue++ )
+ {
+ if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_ViewId ) ) )
+ {
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_SnapLinesDrawing ) ) )
+ {
+ if( pValue->Value >>= aString )
+ {
+ SdrHelpLineList aHelpLines;
+ createHelpLinesFromString( aString, aHelpLines );
+ SetStandardHelpLines( aHelpLines );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_SnapLinesNotes ) ) )
+ {
+ if( pValue->Value >>= aString )
+ {
+ SdrHelpLineList aHelpLines;
+ createHelpLinesFromString( aString, aHelpLines );
+ SetNotesHelpLines( aHelpLines );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_SnapLinesHandout ) ) )
+ {
+ if( pValue->Value >>= aString )
+ {
+ SdrHelpLineList aHelpLines;
+ createHelpLinesFromString( aString, aHelpLines );
+ SetHandoutHelpLines( aHelpLines );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_RulerIsVisible ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetRuler( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_PageKind ) ) )
+ {
+ if( pValue->Value >>= nInt16 )
+ {
+ SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
+ if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
+ SetPageKind( (PageKind)nInt16 );
+
+ SetPageKindOnLoad( (PageKind)nInt16 );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_SelectedPage ) ) )
+ {
+ if( pValue->Value >>= nInt16 )
+ {
+ SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
+ if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
+ SetSelectedPage( (sal_uInt16)nInt16 );
+
+ SetSelectedPageOnLoad( (sal_uInt16)nInt16 );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsLayerMode ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetLayerMode( bBool );
+ }
+ }
+/* else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsQuickEdit ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetQuickEdit( bBool );
+ }
+ }
+*/ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsBigHandles ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetBigHandles( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsDoubleClickTextEdit ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetDoubleClickTextEdit( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsClickChangeRotation ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetClickChangeRotation( bBool );
+ }
+ }
+/* else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsDragWithCopy ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetDragWithCopy( bBool );
+ }
+ }
+*/ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_SlidesPerRow ) ) )
+ {
+ if( pValue->Value >>= nInt16 )
+ {
+ SetSlidesPerRow( (sal_uInt16)nInt16 );
+ }
+ }
+/* #107128# Product managment decided to not make this persistent
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_DrawMode ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ if( rStyleSettings.GetHighContrastMode() )
+ continue;
+ SetDrawMode( (sal_uLong)nInt32 );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_PreviewDrawMode ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
+ SvtAccessibilityOptions aAccOptions;
+ if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
+ continue;
+ SetPreviewDrawMode( (sal_uLong)nInt32 );
+ }
+ }
+*/
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_EditModeStandard ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
+ if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
+ SetViewShEditMode( (EditMode)nInt32, PK_STANDARD );
+ eStandardEditMode = (EditMode)nInt32;
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_EditModeNotes ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
+ if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
+ SetViewShEditMode( (EditMode)nInt32, PK_NOTES );
+ eNotesEditMode = (EditMode)nInt32;
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_EditModeHandout ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ SdDrawDocument* pDoc = dynamic_cast< SdDrawDocument* >( GetModel() );
+ if( pDoc && pDoc->GetDocSh() && ( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocSh()->GetCreateMode() ) )
+ SetViewShEditMode( (EditMode)nInt32, PK_HANDOUT );
+ eHandoutEditMode = (EditMode)nInt32;
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_VisibleAreaTop ) ) )
+ {
+ sal_Int32 nTop = 0;
+ if( pValue->Value >>= nTop )
+ {
+ Rectangle aVisArea( GetVisArea() );
+ aVisArea.nBottom += nTop - aVisArea.nTop;
+ aVisArea.nTop = nTop;
+ SetVisArea( aVisArea );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_VisibleAreaLeft ) ) )
+ {
+ sal_Int32 nLeft = 0;
+ if( pValue->Value >>= nLeft )
+ {
+ Rectangle aVisArea( GetVisArea() );
+ aVisArea.nRight += nLeft - aVisArea.nLeft;
+ aVisArea.nLeft = nLeft;
+ SetVisArea( aVisArea );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_VisibleAreaWidth ) ) )
+ {
+ sal_Int32 nWidth = 0;
+ if( pValue->Value >>= nWidth )
+ {
+ Rectangle aVisArea( GetVisArea() );
+ aVisArea.nRight = aVisArea.nLeft + nWidth - 1;
+ SetVisArea( aVisArea );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_VisibleAreaHeight ) ) )
+ {
+ sal_Int32 nHeight = 0;
+ if( pValue->Value >>= nHeight )
+ {
+ Rectangle aVisArea( GetVisArea() );
+ aVisArea.nBottom = nHeight + aVisArea.nTop - 1;
+ SetVisArea( aVisArea );
+ }
+ }
+
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridIsVisible ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetGridVisible( bBool );
+ }
+ }
+
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsSnapToGrid ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetGridSnap( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridIsFront ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetGridFront( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsSnapToPageMargins ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetBordSnap( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsSnapToSnapLines ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetHlplSnap( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsSnapToObjectFrame ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetOFrmSnap( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsSnapToObjectPoints ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetOPntSnap( bBool );
+ }
+ }
+/* else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsSnapLinesVisible ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetHlplVisible( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsDragStripes ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetDragStripes( bBool );
+ }
+ }
+*/ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsPlusHandlesAlwaysVisible ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetPlusHandlesAlwaysVisible( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsFrameDragSingles ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetFrameDragSingles( bBool );
+ }
+ }
+/* else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsMarkedHitMovesAlways ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetMarkedHitMovesAlways( bBool );
+ }
+ }
+*/ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_EliminatePolyPointLimitAngle ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ SetEliminatePolyPointLimitAngle( nInt32 );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsEliminatePolyPoints ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetEliminatePolyPoints( bBool );
+ }
+ }
+/*
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsLineDraft ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetLineDraft( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsFillDraft ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetFillDraft( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsTextDraft ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetTextDraft( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsGrafDraft ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetGrafDraft( bBool );
+ }
+ }
+*/
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_ActiveLayer ) ) )
+ {
+ if( pValue->Value >>= aString )
+ {
+ SetActiveLayer( aString );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_NoAttribs ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetNoAttribs( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_NoColors ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetNoColors( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridCoarseWidth ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ const Size aCoarse( nInt32, GetGridCoarse().Height() );
+ SetGridCoarse( aCoarse );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridCoarseHeight ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ const Size aCoarse( GetGridCoarse().Width(), nInt32 );
+ SetGridCoarse( aCoarse );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridFineWidth ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ const Size aCoarse( nInt32, GetGridFine().Height() );
+ SetGridFine( aCoarse );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridFineHeight ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ const Size aCoarse( GetGridFine().Width(), nInt32 );
+ SetGridFine( aCoarse );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_IsAngleSnapEnabled ) ) )
+ {
+ if( pValue->Value >>= bBool )
+ {
+ SetAngleSnapEnabled( bBool );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_SnapAngle ) ) )
+ {
+ if( pValue->Value >>= nInt32 )
+ {
+ SetSnapAngle( nInt32 );
+ }
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridSnapWidthXNumerator ) ) )
+ {
+ pValue->Value >>= aSnapGridWidthXNum;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridSnapWidthXDenominator ) ) )
+ {
+ pValue->Value >>= aSnapGridWidthXDom;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridSnapWidthYNumerator ) ) )
+ {
+ pValue->Value >>= aSnapGridWidthYNum;
+ }
+ else if (pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_GridSnapWidthYDenominator ) ) )
+ {
+ pValue->Value >>= aSnapGridWidthYDom;
+ }
+ else if (!bImpress && pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_VisibleLayers ) ) )
+ {
+ SetOfByte aSetOfBytes;
+ aSetOfBytes.PutValue( pValue->Value );
+ SetVisibleLayers( aSetOfBytes );
+ }
+ else if (!bImpress && pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_PrintableLayers ) ) )
+ {
+ SetOfByte aSetOfBytes;
+ aSetOfBytes.PutValue( pValue->Value );
+ SetPrintableLayers( aSetOfBytes );
+ }
+ else if (!bImpress && pValue->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( sUNO_View_LockedLayers ) ) )
+ {
+ SetOfByte aSetOfBytes;
+ aSetOfBytes.PutValue( pValue->Value );
+ SetLockedLayers( aSetOfBytes );
+ }
+ }
+
+ switch (GetPageKindOnLoad())
+ {
+ case PK_STANDARD: SetViewShEditModeOnLoad(meStandardEditMode); break;
+ case PK_NOTES: SetViewShEditModeOnLoad(meNotesEditMode); break;
+ case PK_HANDOUT: SetViewShEditModeOnLoad(meHandoutEditMode); break;
+ default: SetViewShEditModeOnLoad(EM_PAGE); break;
+ }
+
+ const Fraction aSnapGridWidthX( aSnapGridWidthXNum, aSnapGridWidthXDom );
+ const Fraction aSnapGridWidthY( aSnapGridWidthYNum, aSnapGridWidthYDom );
+
+ SetSnapGridWidth( aSnapGridWidthX, aSnapGridWidthY );
+ }
+}
+
+
+
+
+void FrameView::SetPreviousViewShellType (ViewShell::ShellType eType)
+{
+ mePreviousViewShellType = eType;
+}
+
+
+
+
+ViewShell::ShellType FrameView::GetPreviousViewShellType (void) const
+{
+ return mePreviousViewShellType;
+}
+
+
+
+
+void FrameView::SetViewShellTypeOnLoad (ViewShell::ShellType eType)
+{
+ meViewShellTypeOnLoad = eType;
+}
+
+
+
+
+ViewShell::ShellType FrameView::GetViewShellTypeOnLoad (void) const
+{
+ return meViewShellTypeOnLoad;
+}
+
+
+
+
+void FrameView::SetSelectedPage(sal_uInt16 nPage)
+{
+ mnSelectedPage = nPage;
+}
+
+
+
+
+sal_uInt16 FrameView::GetSelectedPage (void) const
+{
+ return mnSelectedPage;
+}
+
+
+
+
+void FrameView::SetIsNavigatorShowingAllShapes (const bool bIsNavigatorShowingAllShapes)
+{
+ mbIsNavigatorShowingAllShapes = bIsNavigatorShowingAllShapes;
+}
+
+
+
+
+bool FrameView::IsNavigatorShowingAllShapes (void) const
+{
+ return mbIsNavigatorShowingAllShapes;
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/grviewsh.cxx b/sd/source/ui/view/grviewsh.cxx
new file mode 100755
index 000000000000..646a437c42bf
--- /dev/null
+++ b/sd/source/ui/view/grviewsh.cxx
@@ -0,0 +1,156 @@
+/*************************************************************************
+ *
+ * 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 "GraphicViewShell.hxx"
+#include "LayerTabBar.hxx"
+#include "FrameView.hxx"
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/scrbar.hxx>
+#include <vcl/salbtype.hxx> // FRound
+
+namespace sd {
+
+static const int TABCONTROL_INITIAL_SIZE = 350;
+
+/*************************************************************************
+|*
+|* Standard-Konstruktor
+|*
+\************************************************************************/
+
+GraphicViewShell::GraphicViewShell (
+ SfxViewFrame* pFrame,
+ ViewShellBase& rViewShellBase,
+ ::Window* pParentWindow,
+ FrameView* pFrameView)
+ : DrawViewShell (
+ pFrame,
+ rViewShellBase,
+ pParentWindow,
+ PK_STANDARD,
+ pFrameView)
+{
+ ConstructGraphicViewShell();
+}
+
+GraphicViewShell::~GraphicViewShell (void)
+{
+}
+
+
+
+
+void GraphicViewShell::ConstructGraphicViewShell(void)
+{
+ meShellType = ST_DRAW;
+
+ mpLayerTabBar.reset (new LayerTabBar(this,GetParentWindow()));
+ mpLayerTabBar->SetSplitHdl(LINK(this,GraphicViewShell,TabBarSplitHandler));
+
+ // pb: #i67363# no layer tabbar on preview mode
+ if ( !GetObjectShell()->IsPreview() )
+ mpLayerTabBar->Show();
+}
+
+
+
+
+void GraphicViewShell::ChangeEditMode (
+ EditMode eMode,
+ bool )
+{
+ // There is no page tab that could be shown instead of the layer tab.
+ // Therefore we have it allways visible regardless of what the caller
+ // said. (We have to change the callers behaviour, of course.)
+ DrawViewShell::ChangeEditMode (eMode, true);
+}
+
+
+
+
+void GraphicViewShell::ArrangeGUIElements (void)
+{
+ if (mpLayerTabBar.get()!=NULL && mpLayerTabBar->IsVisible())
+ {
+ Size aSize = mpLayerTabBar->GetSizePixel();
+ const Size aFrameSize (
+ GetViewFrame()->GetWindow().GetOutputSizePixel());
+
+ if (aSize.Width() == 0)
+ {
+ if (mpFrameView->GetTabCtrlPercent() == 0.0)
+ aSize.Width() = TABCONTROL_INITIAL_SIZE;
+ else
+ aSize.Width() = FRound(aFrameSize.Width()
+ * mpFrameView->GetTabCtrlPercent());
+ }
+ aSize.Height() = GetParentWindow()->GetSettings().GetStyleSettings()
+ .GetScrollBarSize();
+
+ Point aPos (0, maViewSize.Height() - aSize.Height());
+
+ mpLayerTabBar->SetPosSizePixel (aPos, aSize);
+
+ if (aFrameSize.Width() > 0)
+ mpFrameView->SetTabCtrlPercent (
+ (double) maTabControl.GetSizePixel().Width()
+ / aFrameSize.Width());
+ else
+ mpFrameView->SetTabCtrlPercent( 0.0 );
+ }
+
+ DrawViewShell::ArrangeGUIElements();
+}
+
+
+
+
+IMPL_LINK(GraphicViewShell, TabBarSplitHandler, TabBar*, pTabBar)
+{
+ const long int nMax = maViewSize.Width()
+ - maScrBarWH.Width()
+ - pTabBar->GetPosPixel().X();
+
+ Size aTabSize = pTabBar->GetSizePixel();
+ aTabSize.Width() = Min(pTabBar->GetSplitSize(), (long)(nMax-1));
+
+ pTabBar->SetSizePixel (aTabSize);
+
+ Point aPos = pTabBar->GetPosPixel();
+ aPos.X() += aTabSize.Width();
+
+ Size aScrSize (nMax - aTabSize.Width(), maScrBarWH.Height());
+ mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
+
+ return 0;
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/makefile.mk b/sd/source/ui/view/makefile.mk
new file mode 100644
index 000000000000..0ee8280d3fad
--- /dev/null
+++ b/sd/source/ui/view/makefile.mk
@@ -0,0 +1,123 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+
+
+PRJ=..$/..$/..
+
+PROJECTPCH=sd
+PROJECTPCHSOURCE=$(PRJ)$/util$/sd
+PRJNAME=sd
+TARGET=view
+
+AUTOSEG=true
+PRJINC=..$/slidesorter
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ DocumentRenderer.src
+
+SLOFILES = \
+ $(SLO)$/sdview.obj \
+ $(SLO)$/sdview2.obj \
+ $(SLO)$/sdview3.obj \
+ $(SLO)$/sdview4.obj \
+ $(SLO)$/sdview5.obj \
+ $(SLO)$/viewshel.obj \
+ $(SLO)$/viewshe2.obj \
+ $(SLO)$/viewshe3.obj \
+ $(SLO)$/sdwindow.obj \
+ $(SLO)$/drviewsh.obj \
+ $(SLO)$/drviews1.obj \
+ $(SLO)$/drviews2.obj \
+ $(SLO)$/drviews3.obj \
+ $(SLO)$/drviews4.obj \
+ $(SLO)$/drviews5.obj \
+ $(SLO)$/drviews6.obj \
+ $(SLO)$/drviews7.obj \
+ $(SLO)$/drviews8.obj \
+ $(SLO)$/drviews9.obj \
+ $(SLO)$/drviewsa.obj \
+ $(SLO)$/drviewsb.obj \
+ $(SLO)$/drviewsc.obj \
+ $(SLO)$/drviewsd.obj \
+ $(SLO)$/drviewse.obj \
+ $(SLO)$/drviewsf.obj \
+ $(SLO)$/drviewsg.obj \
+ $(SLO)$/drviewsi.obj \
+ $(SLO)$/drviewsj.obj \
+ $(SLO)$/drvwshrg.obj \
+ $(SLO)$/drawview.obj \
+ $(SLO)$/grviewsh.obj \
+ $(SLO)$/outlnvsh.obj \
+ $(SLO)$/outlnvs2.obj \
+ $(SLO)$/presvish.obj \
+ $(SLO)$/outlview.obj \
+ $(SLO)$/tabcontr.obj \
+ $(SLO)$/bmcache.obj \
+ $(SLO)$/drbezob.obj \
+ $(SLO)$/drtxtob.obj \
+ $(SLO)$/drtxtob1.obj \
+ $(SLO)$/sdruler.obj \
+ $(SLO)$/frmview.obj \
+ $(SLO)$/clview.obj \
+ $(SLO)$/zoomlist.obj \
+ $(SLO)$/unmodpg.obj \
+ $(SLO)$/DocumentRenderer.obj \
+ $(SLO)$/FormShellManager.obj \
+ $(SLO)$/GraphicObjectBar.obj \
+ $(SLO)$/GraphicViewShellBase.obj \
+ $(SLO)$/ImpressViewShellBase.obj \
+ $(SLO)$/MediaObjectBar.obj \
+ $(SLO)$/Outliner.obj \
+ $(SLO)$/OutlinerIterator.obj \
+ $(SLO)$/OutlineViewShellBase.obj \
+ $(SLO)$/SlideSorterViewShellBase.obj \
+ $(SLO)$/PresentationViewShellBase.obj \
+ $(SLO)$/ToolBarManager.obj \
+ $(SLO)$/UpdateLockManager.obj \
+ $(SLO)$/ViewClipboard.obj \
+ $(SLO)$/ViewShellBase.obj \
+ $(SLO)$/ViewShellImplementation.obj \
+ $(SLO)$/ViewShellManager.obj \
+ $(SLO)$/ViewShellHint.obj \
+ $(SLO)$/ViewTabBar.obj \
+ $(SLO)$/WindowUpdater.obj \
+ $(SLO)$/viewoverlaymanager.obj
+
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sd/source/ui/view/outlnvs2.cxx b/sd/source/ui/view/outlnvs2.cxx
new file mode 100755
index 000000000000..09777a20392b
--- /dev/null
+++ b/sd/source/ui/view/outlnvs2.cxx
@@ -0,0 +1,648 @@
+/*************************************************************************
+ *
+ * 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 "OutlineViewShell.hxx"
+
+#include <com/sun/star/presentation/XPresentation2.hpp>
+
+#include "app.hrc"
+#include <svx/hlnkitem.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <svl/eitem.hxx>
+#ifndef _ZOOMITEM_HXX //autogen
+#include <svx/zoomitem.hxx>
+#endif
+#include <vcl/msgbox.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/flditem.hxx>
+#include <editeng/editstat.hxx>
+#include "optsitem.hxx"
+#include <unotools/useroptions.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include "Outliner.hxx"
+#include "Window.hxx"
+#include "OutlineViewShell.hxx"
+#include "fubullet.hxx"
+#include "fuolbull.hxx"
+#include "FrameView.hxx"
+#include "fuzoom.hxx"
+#include "fuscale.hxx"
+#include "fuchar.hxx"
+#include "fuinsfil.hxx"
+#include "fuprobjs.hxx"
+#include "futhes.hxx"
+#include "futempl.hxx"
+#include "fusldlg.hxx"
+#include "zoomlist.hxx"
+#include "fuexpand.hxx"
+#include "fusumry.hxx"
+#include "fucushow.hxx"
+#include "drawdoc.hxx"
+#include "sdattr.hxx"
+#include "ViewShellBase.hxx"
+#include "sdabstdlg.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include "DrawViewShell.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::presentation;
+
+namespace sd {
+
+
+/************************************************************************/
+
+/*************************************************************************
+|*
+|* SfxRequests fuer temporaere Funktionen
+|*
+\************************************************************************/
+
+void OutlineViewShell::FuTemporary(SfxRequest &rReq)
+{
+ DeactivateCurrentFunction();
+
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ switch( nSId )
+ {
+ case SID_ATTR_ZOOM:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if ( pArgs )
+ {
+ SvxZoomType eZT = ( ( const SvxZoomItem& ) pArgs->
+ Get( SID_ATTR_ZOOM ) ).GetType();
+ switch( eZT )
+ {
+ case SVX_ZOOM_PERCENT:
+ SetZoom( (long) ( ( const SvxZoomItem& ) pArgs->
+ Get( SID_ATTR_ZOOM ) ).GetValue() );
+ Invalidate( SID_ATTR_ZOOM );
+ Invalidate( SID_ATTR_ZOOMSLIDER );
+ break;
+ default:
+ break;
+ }
+ rReq.Done();
+ }
+ else
+ {
+ // hier den Zoom-Dialog oeffnen
+ SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ }
+ Cancel();
+ }
+ break;
+
+ case SID_ATTR_ZOOMSLIDER:
+ {
+ const SfxItemSet* pArgs = rReq.GetArgs();
+
+ if (pArgs && pArgs->Count () == 1 )
+ {
+ SFX_REQUEST_ARG (rReq, pScale, SfxUInt16Item, SID_ATTR_ZOOMSLIDER, sal_False);
+ if (CHECK_RANGE (5, pScale->GetValue (), 3000))
+ {
+ SetZoom (pScale->GetValue ());
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_ATTR_ZOOM );
+ rBindings.Invalidate( SID_ZOOM_IN );
+ rBindings.Invalidate( SID_ZOOM_OUT );
+ rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
+
+ }
+ }
+
+ Cancel();
+ rReq.Done ();
+ break;
+ }
+
+ case SID_ZOOM_OUT:
+ {
+ SetCurrentFunction( FuZoom::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) );
+ // Beendet sich selbst, kein Cancel() notwendig!
+ rReq.Done();
+ }
+ break;
+
+ case SID_SIZE_REAL:
+ {
+ SetZoom( 100 );
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
+ GetActiveWindow()->GetOutputSizePixel()) );
+ mpZoomList->InsertZoomRect(aVisAreaWin);
+ Invalidate( SID_ATTR_ZOOM );
+ Invalidate( SID_ATTR_ZOOMSLIDER );
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_ZOOM_IN:
+ {
+ SetZoom( Max( (long) ( GetActiveWindow()->GetZoom() / 2 ), (long) GetActiveWindow()->GetMinZoom() ) );
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0),
+ GetActiveWindow()->GetOutputSizePixel()) );
+ mpZoomList->InsertZoomRect(aVisAreaWin);
+ Invalidate( SID_ATTR_ZOOM );
+ Invalidate( SID_ZOOM_OUT);
+ Invalidate( SID_ZOOM_IN );
+ Invalidate( SID_ATTR_ZOOMSLIDER );
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_COLLAPSE_ALL:
+ {
+ pOutlinerView->CollapseAll();
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_COLLAPSE:
+ {
+ pOutlinerView->Collapse();
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_EXPAND_ALL:
+ {
+ pOutlinerView->ExpandAll();
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_EXPAND:
+ {
+ pOutlinerView->Expand();
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTLINE_FORMAT:
+ {
+ ::Outliner* pOutl = pOutlinerView->GetOutliner();
+ pOutl->SetFlatMode( !pOutl->IsFlatMode() );
+ Invalidate( SID_COLORVIEW );
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_SELECTALL:
+ {
+ ::Outliner* pOutl = pOlView->GetOutliner();
+ sal_uLong nParaCount = pOutl->GetParagraphCount();
+ if (nParaCount > 0)
+ {
+ pOutlinerView->SelectRange( 0, (sal_uInt16) nParaCount );
+ }
+ Cancel();
+ }
+ break;
+
+ case SID_PRESENTATION:
+ case SID_REHEARSE_TIMINGS:
+ {
+ pOlView->PrepareClose();
+
+ Reference< XPresentation2 > xPresentation( GetDoc()->getPresentation() );
+ if( xPresentation.is() )
+ {
+ if( ( SID_REHEARSE_TIMINGS != rReq.GetSlot() ) )
+ xPresentation->start();
+ else
+ xPresentation->rehearseTimings();
+ }
+ rReq.Done();
+ }
+ break;
+
+ case SID_COLORVIEW:
+ {
+ ::Outliner* pOutl = pOutlinerView->GetOutliner();
+ sal_uLong nCntrl = pOutl->GetControlWord();
+
+ if ( !(nCntrl & EE_CNTRL_NOCOLORS) )
+ {
+ // Farbansicht ist eingeschaltet: ausschalten
+ pOutl->SetControlWord(nCntrl | EE_CNTRL_NOCOLORS);
+ }
+ else
+ {
+ // Farbansicht ist ausgeschaltet: einschalten
+ pOutl->SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS);
+ }
+
+ InvalidateWindows();
+ Invalidate( SID_COLORVIEW );
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_STYLE_EDIT:
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ {
+ if( rReq.GetArgs() )
+ {
+ SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ Cancel();
+ }
+
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_PRESENTATION_DLG:
+ {
+ SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_CUSTOMSHOW_DLG:
+ {
+ SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+ }
+
+ if(HasCurrentFunction())
+ GetCurrentFunction()->Activate();
+
+ Invalidate( SID_OUTLINE_COLLAPSE_ALL );
+ Invalidate( SID_OUTLINE_COLLAPSE );
+ Invalidate( SID_OUTLINE_EXPAND_ALL );
+ Invalidate( SID_OUTLINE_EXPAND );
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_OUTLINE_LEFT );
+ rBindings.Invalidate( SID_OUTLINE_RIGHT );
+ rBindings.Invalidate( SID_OUTLINE_UP );
+ rBindings.Invalidate( SID_OUTLINE_DOWN );
+
+ Invalidate( SID_OUTLINE_FORMAT );
+ Invalidate( SID_COLORVIEW );
+ Invalidate(SID_CUT);
+ Invalidate(SID_COPY);
+ Invalidate(SID_PASTE);
+}
+
+void OutlineViewShell::FuTemporaryModify(SfxRequest &rReq)
+{
+ OutlineViewModelChangeGuard aGuard( *pOlView );
+
+ DeactivateCurrentFunction();
+
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
+ sal_uInt16 nSId = rReq.GetSlot();
+
+ switch( nSId )
+ {
+ case SID_HYPERLINK_SETLINK:
+ {
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ if (pReqArgs)
+ {
+ SvxHyperlinkItem* pHLItem =
+ (SvxHyperlinkItem*) &pReqArgs->Get(SID_HYPERLINK_SETLINK);
+
+ SvxFieldItem aURLItem(SvxURLField(pHLItem->GetURL(),
+ pHLItem->GetName(),
+ SVXURLFORMAT_REPR), EE_FEATURE_FIELD);
+ ESelection aSel( pOutlinerView->GetSelection() );
+ pOutlinerView->InsertField(aURLItem);
+ if ( aSel.nStartPos <= aSel.nEndPos )
+ aSel.nEndPos = aSel.nStartPos + 1;
+ else
+ aSel.nStartPos = aSel.nEndPos + 1;
+ pOutlinerView->SetSelection( aSel );
+ }
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case FN_INSERT_SOFT_HYPHEN:
+ case FN_INSERT_HARDHYPHEN:
+ case FN_INSERT_HARD_SPACE:
+ case SID_INSERT_RLM :
+ case SID_INSERT_LRM :
+ case SID_INSERT_ZWNBSP :
+ case SID_INSERT_ZWSP:
+ case SID_CHARMAP:
+ {
+ SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_OUTLINE_BULLET:
+ {
+ SetCurrentFunction( FuOutlineBullet::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_THESAURUS:
+ {
+ SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_CHAR_DLG:
+ {
+ SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ Cancel();
+ }
+ break;
+
+ case SID_INSERTFILE:
+ {
+ SetCurrentFunction( FuInsertFile::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) );
+ Cancel();
+ }
+ break;
+
+ case SID_PRESENTATIONOBJECT:
+ {
+ SetCurrentFunction( FuPresentationObjects::Create(this, GetActiveWindow(), pOlView, GetDoc(), rReq) );
+ Cancel();
+ }
+ break;
+
+ case SID_SET_DEFAULT:
+ {
+ // 1. Selektion merken (kriegt die eselige EditEngine nicht selbst
+ // auf die Reihe!)
+ // 2. Update auf False (sonst flackert's noch staerker
+ // an allen selektierten Absaetzen:
+ // a. deren Vorlage nochmal setzen, um absatzweite harte Attribute
+ // zu entfernen
+ // b. harte Zeichenattribute loeschen
+ // 3. Update auf True und Selektion wieder setzen
+ /*
+ ESelection aEsel= pOutlinerView->GetSelection();
+ Outliner* pOutl = pOutlinerView->GetOutliner();
+ pOutl->SetUpdateMode(sal_False);
+ List* pSelectedParas = pOutlinerView->CreateSelectionList();
+ Paragraph* pPara = (Paragraph*)pSelectedParas->First();
+ while (pPara)
+ {
+ sal_uLong nParaPos = pOutl->GetAbsPos(pPara);
+ String aName;
+ SfxStyleFamily aFamily;
+ pOutl->GetStyleSheet(nParaPos, aName, aFamily);
+ pOutl->SetStyleSheet(nParaPos, aName, aFamily);
+ pOutl->QuickRemoveCharAttribs(nParaPos);
+ pPara = (Paragraph*)pSelectedParas->Next();
+ }
+ delete pSelectedParas;
+ pOutl->SetUpdateMode(sal_True);
+ pOutlinerView->SetSelection(aEsel);
+ */
+ pOutlinerView->RemoveAttribs(sal_True); // sal_True = auch Absatzattribute
+ Cancel();
+ rReq.Done();
+ }
+ break;
+
+ case SID_SUMMARY_PAGE:
+ {
+ pOlView->SetSelectedPages();
+ SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ pOlView->GetOutliner()->Clear();
+ pOlView->FillOutliner();
+ pOlView->GetActualPage();
+ Cancel();
+ }
+ break;
+
+ case SID_EXPAND_PAGE:
+ {
+ pOlView->SetSelectedPages();
+ SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), pOlView, GetDoc(), rReq ) );
+ pOlView->GetOutliner()->Clear();
+ pOlView->FillOutliner();
+ pOlView->GetActualPage();
+ Cancel();
+ }
+ break;
+
+ case SID_INSERT_FLD_DATE_FIX:
+ case SID_INSERT_FLD_DATE_VAR:
+ case SID_INSERT_FLD_TIME_FIX:
+ case SID_INSERT_FLD_TIME_VAR:
+ case SID_INSERT_FLD_AUTHOR:
+ case SID_INSERT_FLD_PAGE:
+ case SID_INSERT_FLD_PAGES:
+ case SID_INSERT_FLD_FILE:
+ {
+ SvxFieldItem* pFieldItem = 0;
+
+ switch( nSId )
+ {
+ case SID_INSERT_FLD_DATE_FIX:
+ pFieldItem = new SvxFieldItem(
+ SvxDateField( Date(), SVXDATETYPE_FIX ), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_DATE_VAR:
+ pFieldItem = new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_TIME_FIX:
+ pFieldItem = new SvxFieldItem(
+ SvxExtTimeField( Time(), SVXTIMETYPE_FIX ), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_TIME_VAR:
+ pFieldItem = new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_AUTHOR:
+ {
+ SvtUserOptions aUserOptions;
+ pFieldItem = new SvxFieldItem(
+ SvxAuthorField(
+ aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() )
+ , EE_FEATURE_FIELD );
+ }
+ break;
+
+ case SID_INSERT_FLD_PAGE:
+ pFieldItem = new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_PAGES:
+ pFieldItem = new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD );
+ break;
+
+ case SID_INSERT_FLD_FILE:
+ {
+ String aName;
+ if( GetDocSh()->HasName() )
+ aName = GetDocSh()->GetMedium()->GetName();
+ //else
+ // aName = GetDocSh()->GetName();
+ pFieldItem = new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD );
+ }
+ break;
+ }
+
+ const SvxFieldItem* pOldFldItem = pOutlinerView->GetFieldAtSelection();
+
+ if( pOldFldItem && ( pOldFldItem->GetField()->ISA( SvxURLField ) ||
+ pOldFldItem->GetField()->ISA( SvxDateField ) ||
+ pOldFldItem->GetField()->ISA( SvxTimeField ) ||
+ pOldFldItem->GetField()->ISA( SvxExtTimeField ) ||
+ pOldFldItem->GetField()->ISA( SvxExtFileField ) ||
+ pOldFldItem->GetField()->ISA( SvxAuthorField ) ||
+ pOldFldItem->GetField()->ISA( SvxPageField ) ||
+ pOldFldItem->GetField()->ISA( SvxPagesField )) )
+ {
+ // Feld selektieren, so dass es beim Insert geloescht wird
+ ESelection aSel = pOutlinerView->GetSelection();
+ if( aSel.nStartPos == aSel.nEndPos )
+ aSel.nEndPos++;
+ pOutlinerView->SetSelection( aSel );
+ }
+
+ if( pFieldItem )
+ pOutlinerView->InsertField( *pFieldItem );
+
+ delete pFieldItem;
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+
+ case SID_MODIFY_FIELD:
+ {
+ const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection();
+
+ if( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
+ pFldItem->GetField()->ISA( SvxAuthorField ) ||
+ pFldItem->GetField()->ISA( SvxExtFileField ) ||
+ pFldItem->GetField()->ISA( SvxExtTimeField ) ) )
+ {
+ // Dialog...
+ SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
+ AbstractSdModifyFieldDlg* pDlg = pFact ? pFact->CreateSdModifyFieldDlg(GetActiveWindow(), pFldItem->GetField(), pOutlinerView->GetAttribs() ) : 0;
+ if( pDlg && (pDlg->Execute() == RET_OK) )
+ {
+ SvxFieldData* pField = pDlg->GetField();
+ if( pField )
+ {
+ SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
+ //pOLV->DeleteSelected(); <-- fehlt leider !
+ // Feld selektieren, so dass es beim Insert geloescht wird
+ ESelection aSel = pOutlinerView->GetSelection();
+ sal_Bool bSel = sal_True;
+ if( aSel.nStartPos == aSel.nEndPos )
+ {
+ bSel = sal_False;
+ aSel.nEndPos++;
+ }
+ pOutlinerView->SetSelection( aSel );
+
+ pOutlinerView->InsertField( aFieldItem );
+
+ // Selektion wird wieder in den Ursprungszustand gebracht
+ if( !bSel )
+ aSel.nEndPos--;
+ pOutlinerView->SetSelection( aSel );
+
+ delete pField;
+ }
+
+ SfxItemSet aSet( pDlg->GetItemSet() );
+ if( aSet.Count() )
+ {
+ pOutlinerView->SetAttribs( aSet );
+
+ ::Outliner* pOutliner = pOutlinerView->GetOutliner();
+ if( pOutliner )
+ pOutliner->UpdateFields();
+ }
+ }
+ delete pDlg;
+ }
+
+ Cancel();
+ rReq.Ignore ();
+ }
+ break;
+ }
+
+ if(HasCurrentFunction())
+ GetCurrentFunction()->Activate();
+
+ Invalidate( SID_OUTLINE_COLLAPSE_ALL );
+ Invalidate( SID_OUTLINE_COLLAPSE );
+ Invalidate( SID_OUTLINE_EXPAND_ALL );
+ Invalidate( SID_OUTLINE_EXPAND );
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_OUTLINE_LEFT );
+ rBindings.Invalidate( SID_OUTLINE_RIGHT );
+ rBindings.Invalidate( SID_OUTLINE_UP );
+ rBindings.Invalidate( SID_OUTLINE_DOWN );
+
+ Invalidate( SID_OUTLINE_FORMAT );
+ Invalidate( SID_COLORVIEW );
+ Invalidate(SID_CUT);
+ Invalidate(SID_COPY);
+ Invalidate(SID_PASTE);
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
new file mode 100755
index 000000000000..fcae0d528c52
--- /dev/null
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -0,0 +1,2165 @@
+/*************************************************************************
+ *
+ * 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 "OutlineViewShell.hxx"
+
+#include "ViewShellImplementation.hxx"
+#include <memory>
+#include "helpids.h"
+#include "app.hrc"
+#include <svx/hyprlink.hxx>
+#include <svx/hyperdlg.hxx>
+#include <svx/zoomslideritem.hxx>
+
+#include <sfx2/objface.hxx>
+#include <sot/exchange.hxx>
+#include <svx/ruler.hxx>
+#include <svx/zoomitem.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/flditem.hxx>
+#include <sfx2/shell.hxx>
+#include <sfx2/templdlg.hxx>
+#include <sfx2/viewfac.hxx>
+#include <sfx2/request.hxx>
+#include <svx/hlnkitem.hxx>
+#include <svx/svdotext.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/scrbar.hxx>
+#include <svl/whiter.hxx>
+#include <editeng/editstat.hxx>
+#include <svl/itempool.hxx>
+#include <sfx2/tplpitem.hxx>
+#include <svx/svdorect.hxx>
+#include <sot/formats.hxx>
+#include <com/sun/star/linguistic2/XThesaurus.hpp>
+#include <com/sun/star/i18n/TransliterationModules.hpp>
+#include <com/sun/star/i18n/TransliterationModulesExtra.hpp>
+#include <editeng/unolingu.hxx>
+#include <comphelper/processfactory.hxx>
+#include <editeng/outlobj.hxx>
+#include <svl/cjkoptions.hxx>
+#include <svtools/cliplistener.hxx>
+#include <svl/srchitem.hxx>
+#include <editeng/editobj.hxx>
+#include "fubullet.hxx"
+#include "optsitem.hxx"
+
+#include "strings.hrc"
+#include "glob.hrc"
+#include "res_bmp.hrc"
+#include "Outliner.hxx"
+#include "Window.hxx"
+#include "TextObjectBar.hxx"
+#include "drawdoc.hxx"
+#include "sdresid.hxx"
+#include "sdpage.hxx"
+#include "fuoltext.hxx"
+#include "FrameView.hxx"
+#include "zoomlist.hxx"
+#include "stlsheet.hxx"
+#include "slideshow.hxx"
+#include "SdUnoOutlineView.hxx"
+#include "SpellDialogChildWindow.hxx"
+
+#include "AccessibleOutlineView.hxx"
+#include "ViewShellBase.hxx"
+#include "ViewShellManager.hxx"
+#include "DrawController.hxx"
+#include "framework/FrameworkHelper.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::linguistic2;
+
+using namespace sd;
+#define OutlineViewShell
+#include "sdslots.hxx"
+
+namespace sd {
+
+#define MIN_ZOOM 10 // Minimaler Zoomfaktor
+#define MAX_ZOOM 1000 // Maximaler Zoomfaktor
+
+/************************************************************************/
+
+
+/*************************************************************************
+|*
+|* SFX-Slotmap und Standardinterface deklarieren
+|*
+\************************************************************************/
+
+
+SFX_IMPL_INTERFACE(OutlineViewShell, SfxShell, SdResId(STR_OUTLINEVIEWSHELL))
+{
+ SFX_POPUPMENU_REGISTRATION( SdResId(RID_OUTLINE_POPUP) );
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_FULLSCREEN | SFX_VISIBILITY_SERVER,
+ SdResId(RID_OUTLINE_TOOLBOX) );
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER | SFX_VISIBILITY_READONLYDOC,
+ SdResId(RID_DRAW_VIEWER_TOOLBOX) );
+ SFX_CHILDWINDOW_REGISTRATION( SfxTemplateDialogWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxHyperlinkDlgWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SvxHlinkDlgWrapper::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( ::sd::SpellDialogChildWindow::GetChildWindowId() );
+ SFX_CHILDWINDOW_REGISTRATION( SID_SEARCH_DLG );
+}
+
+
+TYPEINIT1( OutlineViewShell, ViewShell );
+
+
+/*************************************************************************
+|*
+|* gemeinsamer Initialiserungsanteil der beiden Konstruktoren
+|*
+\************************************************************************/
+
+void OutlineViewShell::Construct(DrawDocShell* )
+{
+ sal_Bool bModified = GetDoc()->IsChanged();
+
+ meShellType = ST_OUTLINE;
+ Size aSize(29700, 21000);
+ Point aWinPos (0, 0);
+ Point aViewOrigin(0, 0);
+ GetActiveWindow()->SetMinZoomAutoCalc(sal_False);
+ GetActiveWindow()->SetMinZoom( MIN_ZOOM );
+ GetActiveWindow()->SetMaxZoom( MAX_ZOOM );
+ InitWindows(aViewOrigin, aSize, aWinPos);
+ pOlView = new OutlineView(GetDocSh(), GetActiveWindow(), this);
+ mpView = pOlView; // Pointer der Basisklasse ViewShell
+
+ SetPool( &GetDoc()->GetPool() );
+
+ SetZoom(69);
+
+ // Einstellungen der FrameView uebernehmen
+ ReadFrameViewData(mpFrameView);
+
+ ::Outliner* pOutl = pOlView->GetOutliner();
+ pOutl->SetUpdateMode(sal_True);
+
+ if (!bModified)
+ {
+ pOutl->ClearModifyFlag();
+ }
+
+ pLastPage = GetActualPage();
+
+ String aName( RTL_CONSTASCII_USTRINGPARAM( "OutlineViewShell" ));
+ SetName (aName);
+
+ SetHelpId( SD_IF_SDOUTLINEVIEWSHELL );
+ GetActiveWindow()->SetHelpId( HID_SDOUTLINEVIEWSHELL );
+ GetActiveWindow()->SetUniqueId( HID_SDOUTLINEVIEWSHELL );
+}
+
+
+
+
+Reference<drawing::XDrawSubController> OutlineViewShell::CreateSubController (void)
+{
+ Reference<drawing::XDrawSubController> xSubController;
+
+ if (IsMainViewShell())
+ {
+ // Create uno sub controller for the main view shell.
+ xSubController = Reference<drawing::XDrawSubController>(
+ new SdUnoOutlineView (
+ GetViewShellBase().GetDrawController(),
+ *this,
+ *GetView()));
+ }
+
+ return xSubController;
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Standard-Konstruktor, Fenster duerfen nicht automatisch zentrieren
+|*
+\************************************************************************/
+
+OutlineViewShell::OutlineViewShell (
+ SfxViewFrame* pFrame,
+ ViewShellBase& rViewShellBase,
+ ::Window* pParentWindow,
+ FrameView* pFrameViewArgument)
+ : ViewShell(pFrame, pParentWindow, rViewShellBase),
+ pOlView(NULL),
+ pLastPage( NULL ),
+ pClipEvtLstnr(NULL),
+ bPastePossible(false),
+ mbInitialized(false)
+
+{
+ if (pFrameViewArgument != NULL)
+ mpFrameView = pFrameViewArgument;
+ else
+ mpFrameView = new FrameView(GetDoc());
+
+ mpFrameView->Connect();
+
+ Construct(GetDocSh());
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+OutlineViewShell::~OutlineViewShell()
+{
+ DisposeFunctions();
+
+ delete pOlView;
+
+ mpFrameView->Disconnect();
+
+ if ( pClipEvtLstnr )
+ {
+ pClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_False );
+ pClipEvtLstnr->ClearCallbackLink(); // #103849# prevent callback if another thread is waiting
+ pClipEvtLstnr->release();
+ }
+}
+
+
+
+
+void OutlineViewShell::Shutdown (void)
+{
+ ViewShell::Shutdown();
+
+ PrepareClose();
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Paint-Methode: das Ereignis wird vom Fenster pWindow an
+|* die Viewshell und die aktuelle Funktion weitergeleitet
+|*
+\************************************************************************/
+
+void OutlineViewShell::Paint(const Rectangle& rRect, ::sd::Window* pWin)
+{
+ if (pOlView)
+ {
+ pOlView->Paint(rRect, pWin);
+ }
+
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->Paint(rRect, pWin);
+ }
+}
+
+void OutlineViewShell::ArrangeGUIElements ()
+{
+ // Retrieve the current size (thickness) of the scroll bars. That is
+ // the width of the vertical and the height of the horizontal scroll
+ // bar.
+ int nScrollBarSize =
+ GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize();
+ maScrBarWH = Size (nScrollBarSize, nScrollBarSize);
+
+ ViewShell::ArrangeGUIElements ();
+
+ ::sd::Window* pWindow = mpContentWindow.get();
+ if (pWindow != NULL)
+ {
+ pWindow->SetMinZoomAutoCalc(sal_False);
+
+ // pWindow->SetPosSizePixel(rNewPos, Size(nSizeX, nSizeY));
+
+ // OutputArea der OutlinerView aendern
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
+
+ Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
+// aWin.nLeft = pOlView->GetPageNumberWidthPixel();
+
+ aWin = pWindow->PixelToLogic(aWin);
+ pOutlinerView->SetOutputArea(aWin);
+
+ Rectangle aVis = pOutlinerView->GetVisArea();
+
+ Rectangle aText = Rectangle(Point(0,0),
+ Size(pOlView->GetPaperWidth(),
+ pOlView->GetOutliner()->GetTextHeight()));
+ aText.Bottom() += aWin.GetHeight();
+
+ if (!aWin.IsEmpty()) // nicht beim Oeffnen
+ {
+ InitWindows(Point(0,0), aText.GetSize(), Point(aVis.TopLeft()));
+ UpdateScrollBars();
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Controller bearbeiten
+|*
+\************************************************************************/
+
+void OutlineViewShell::ExecCtrl(SfxRequest &rReq)
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch ( nSlot )
+ {
+ case SID_MAIL_SCROLLBODY_PAGEDOWN:
+ {
+ ExecReq( rReq );
+ break;
+ }
+
+ case SID_OPT_LOCALE_CHANGED:
+ {
+ pOlView->GetOutliner()->UpdateFields();
+ UpdatePreview( GetActualPage() );
+ rReq.Done();
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
+
+
+void OutlineViewShell::AddWindow (::sd::Window* pWin)
+{
+ pOlView->AddWindowToPaintView(pWin);
+}
+
+
+
+
+void OutlineViewShell::RemoveWindow (::sd::Window* pWin)
+{
+ pOlView->DeleteWindowFromPaintView(pWin);
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Activate(), beim ersten Aufruf erfolgt ein Update der Felder
+|*
+\************************************************************************/
+void OutlineViewShell::Activate( sal_Bool bIsMDIActivate )
+{
+ if ( ! mbInitialized)
+ {
+ mbInitialized = true;
+ SfxRequest aRequest (SID_EDIT_OUTLINER, 0, GetDoc()->GetItemPool());
+ FuPermanent (aRequest);
+ }
+
+ ViewShell::Activate( bIsMDIActivate );
+ pOlView->SetLinks();
+ pOlView->ConnectToApplication();
+
+ if( bIsMDIActivate )
+ {
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
+ ::Outliner* pOutl = pOutlinerView->GetOutliner();
+ pOutl->UpdateFields();
+ }
+}
+
+/*************************************************************************
+|*
+|* Deactivate()
+|*
+\************************************************************************/
+void OutlineViewShell::Deactivate( sal_Bool bIsMDIActivate )
+{
+ pOlView->DisconnectFromApplication();
+
+ // #96416# Links must be kept also on deactivated viewshell, to allow drag'n'drop
+ // to function properly
+ // pOlView->ResetLinks();
+
+ ViewShell::Deactivate( bIsMDIActivate );
+}
+
+/*************************************************************************
+|*
+|* Status von Controller-SfxSlots setzen
+|*
+\************************************************************************/
+void OutlineViewShell::GetCtrlState(SfxItemSet &rSet)
+{
+ if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_HYPERLINK_GETLINK))
+ {
+ SvxHyperlinkItem aHLinkItem;
+
+ OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
+ if (pOLV)
+ {
+ const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
+ if (pFieldItem)
+ {
+ ESelection aSel = pOLV->GetSelection();
+ if ( abs( aSel.nEndPos - aSel.nStartPos ) == 1 )
+ {
+ const SvxFieldData* pField = pFieldItem->GetField();
+ if ( pField->ISA(SvxURLField) )
+ {
+ aHLinkItem.SetName(((const SvxURLField*) pField)->GetRepresentation());
+ aHLinkItem.SetURL(((const SvxURLField*) pField)->GetURL());
+ aHLinkItem.SetTargetFrame(((const SvxURLField*) pField)->GetTargetFrame());
+ }
+ }
+ }
+ }
+ rSet.Put(aHLinkItem);
+ }
+ rSet.Put( SfxBoolItem( SID_READONLY_MODE, GetDocSh()->IsReadOnly() ) );
+
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
+ rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, sal_True ) );
+
+ if ( SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_HALFWIDTH) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_FULLWIDTH) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_HIRAGANA) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_TRANSLITERATE_KATAGANA) )
+ {
+ SvtCJKOptions aCJKOptions;
+ if( !aCJKOptions.IsChangeCaseMapEnabled() )
+ {
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_False );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_False );
+ rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
+ rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
+ rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
+ rSet.DisableItem( SID_TRANSLITERATE_KATAGANA );
+ }
+ else
+ {
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, sal_True );
+ GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAGANA, sal_True );
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* SfxRequests fuer Support-Funktionen
+|*
+\************************************************************************/
+
+void OutlineViewShell::FuSupport(SfxRequest &rReq)
+{
+ if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
+ GetDocSh()->SetStyleFamily(((SfxUInt16Item&)rReq.GetArgs()->Get( SID_STYLE_FAMILY )).GetValue());
+
+ sal_Bool bPreviewState = sal_False;
+ sal_uLong nSlot = rReq.GetSlot();
+
+ std::auto_ptr< OutlineViewModelChangeGuard > aGuard;
+ if( pOlView && (
+ (nSlot == SID_TRANSLITERATE_SENTENCE_CASE) ||
+ (nSlot == SID_TRANSLITERATE_TITLE_CASE) ||
+ (nSlot == SID_TRANSLITERATE_TOGGLE_CASE) ||
+ (nSlot == SID_TRANSLITERATE_UPPER) ||
+ (nSlot == SID_TRANSLITERATE_LOWER) ||
+ (nSlot == SID_TRANSLITERATE_HALFWIDTH) ||
+ (nSlot == SID_TRANSLITERATE_FULLWIDTH) ||
+ (nSlot == SID_TRANSLITERATE_HIRAGANA) ||
+ (nSlot == SID_TRANSLITERATE_KATAGANA) ||
+ (nSlot == SID_CUT) ||
+// (nSlot == SID_COPY) ||
+ (nSlot == SID_PASTE) ||
+ (nSlot == SID_DELETE)))
+ {
+ aGuard.reset( new OutlineViewModelChangeGuard( *pOlView ) );
+ }
+
+ switch ( nSlot )
+ {
+ case SID_CUT:
+ {
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->DoCut();
+ }
+ else if (pOlView)
+ {
+ pOlView->DoCut();
+ }
+ rReq.Done();
+ bPreviewState = sal_True;
+ }
+ break;
+
+ case SID_COPY:
+ {
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->DoCopy();
+ }
+ else if (pOlView)
+ {
+ pOlView->DoCopy();
+ }
+ rReq.Done();
+ bPreviewState = sal_True;
+ }
+ break;
+
+ case SID_PASTE:
+ {
+ OutlineViewPageChangesGuard aGuard2(pOlView);
+
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->DoPaste();
+ }
+ else if (pOlView)
+ {
+ pOlView->DoPaste();
+ }
+ rReq.Done();
+ bPreviewState = sal_True;
+ }
+ break;
+
+ case SID_DELETE:
+ {
+ if( pOlView )
+ {
+ OutlinerView* pOutlView = pOlView->GetViewByWindow(GetActiveWindow());
+ if (pOutlView)
+ {
+ OutlineViewPageChangesGuard aGuard2(pOlView);
+
+ KeyCode aKCode(KEY_DELETE);
+ KeyEvent aKEvt( 0, aKCode );
+ pOutlView->PostKeyEvent(aKEvt);
+
+ FunctionReference xFunc( GetCurrentFunction() );
+ FuOutlineText* pFuOutlineText = dynamic_cast< FuOutlineText* >( xFunc.get() );
+ if( pFuOutlineText )
+ pFuOutlineText->UpdateForKeyPress (aKEvt);
+ }
+ }
+ rReq.Done();
+ bPreviewState = sal_True;
+ }
+ break;
+
+ case SID_DRAWINGMODE:
+ case SID_NOTESMODE:
+ case SID_HANDOUTMODE:
+ case SID_DIAMODE:
+ case SID_OUTLINEMODE:
+ framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
+ nSlot,
+ rReq);
+ rReq.Done();
+ break;
+
+ case SID_RULER:
+ SetRuler( !HasRuler() );
+ Invalidate( SID_RULER );
+ rReq.Done();
+ break;
+
+ case SID_ZOOM_PREV:
+ {
+ if (mpZoomList->IsPreviousPossible())
+ {
+ // Vorheriges ZoomRect einstellen
+ SetZoomRect(mpZoomList->GetPreviousZoomRect());
+ }
+ rReq.Done ();
+ }
+ break;
+
+ case SID_ZOOM_NEXT:
+ {
+ if (mpZoomList->IsNextPossible())
+ {
+ // Naechstes ZoomRect einstellen
+ SetZoomRect(mpZoomList->GetNextZoomRect());
+ }
+ rReq.Done ();
+ }
+ break;
+
+ case SID_AUTOSPELL_CHECK:
+ {
+ GetDoc()->SetOnlineSpell(!GetDoc()->GetOnlineSpell());
+ rReq.Done ();
+ }
+ break;
+
+ case SID_TRANSLITERATE_SENTENCE_CASE:
+ case SID_TRANSLITERATE_TITLE_CASE:
+ case SID_TRANSLITERATE_TOGGLE_CASE:
+ case SID_TRANSLITERATE_UPPER:
+ case SID_TRANSLITERATE_LOWER:
+ case SID_TRANSLITERATE_HALFWIDTH:
+ case SID_TRANSLITERATE_FULLWIDTH:
+ case SID_TRANSLITERATE_HIRAGANA:
+ case SID_TRANSLITERATE_KATAGANA:
+ {
+ OutlinerView* pOLV = pOlView->GetViewByWindow( GetActiveWindow() );
+ if( pOLV )
+ {
+ using namespace ::com::sun::star::i18n;
+ sal_Int32 nType = 0;
+
+ switch( nSlot )
+ {
+ case SID_TRANSLITERATE_SENTENCE_CASE:
+ nType = TransliterationModulesExtra::SENTENCE_CASE;
+ break;
+ case SID_TRANSLITERATE_TITLE_CASE:
+ nType = TransliterationModulesExtra::TITLE_CASE;
+ break;
+ case SID_TRANSLITERATE_TOGGLE_CASE:
+ nType = TransliterationModulesExtra::TOGGLE_CASE;
+ break;
+ case SID_TRANSLITERATE_UPPER:
+ nType = TransliterationModules_LOWERCASE_UPPERCASE;
+ break;
+ case SID_TRANSLITERATE_LOWER:
+ nType = TransliterationModules_UPPERCASE_LOWERCASE;
+ break;
+ case SID_TRANSLITERATE_HALFWIDTH:
+ nType = TransliterationModules_FULLWIDTH_HALFWIDTH;
+ break;
+ case SID_TRANSLITERATE_FULLWIDTH:
+ nType = TransliterationModules_HALFWIDTH_FULLWIDTH;
+ break;
+ case SID_TRANSLITERATE_HIRAGANA:
+ nType = TransliterationModules_KATAKANA_HIRAGANA;
+ break;
+ case SID_TRANSLITERATE_KATAGANA:
+ nType = TransliterationModules_HIRAGANA_KATAKANA;
+ break;
+ }
+
+ pOLV->TransliterateText( nType );
+ }
+
+ rReq.Done();
+ bPreviewState = sal_True;
+ }
+ break;
+
+ // #96090# added Undo/Redo handling
+ case SID_UNDO :
+ {
+ OutlineViewPageChangesGuard aGuard2(pOlView);
+ ImpSidUndo(sal_False, rReq);
+ }
+ break;
+ case SID_REDO :
+ {
+ OutlineViewPageChangesGuard aGuard2(pOlView);
+ ImpSidRedo(sal_False, rReq);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if( bPreviewState )
+ Invalidate( SID_PREVIEW_STATE );
+
+ Invalidate(SID_CUT);
+ Invalidate(SID_COPY);
+ Invalidate(SID_PASTE);
+}
+
+/*************************************************************************
+|*
+|* SfxRequests fuer permanente Funktionen
+|*
+\************************************************************************/
+
+void OutlineViewShell::FuPermanent(SfxRequest &rReq)
+{
+ if(HasCurrentFunction())
+ {
+ DeactivateCurrentFunction(true);
+ }
+
+ switch ( rReq.GetSlot() )
+ {
+ case SID_EDIT_OUTLINER:
+ {
+ ::Outliner* pOutl = pOlView->GetOutliner();
+ if( pOutl )
+ {
+ pOutl->GetUndoManager().Clear();
+ pOutl->UpdateFields();
+ }
+
+ SetCurrentFunction( FuOutlineText::Create(this,GetActiveWindow(),pOlView,GetDoc(),rReq) );
+
+ rReq.Done();
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if(HasOldFunction())
+ {
+ GetOldFunction()->Deactivate();
+ SetOldFunction(0);
+ }
+
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->Activate();
+ SetOldFunction(GetCurrentFunction());
+ }
+}
+
+
+IMPL_LINK( OutlineViewShell, ClipboardChanged, TransferableDataHelper*, pDataHelper )
+{
+ if ( pDataHelper )
+ {
+ bPastePossible = ( pDataHelper->GetFormatCount() != 0 &&
+ ( pDataHelper->HasFormat( FORMAT_STRING ) ||
+ pDataHelper->HasFormat( FORMAT_RTF ) ||
+ pDataHelper->HasFormat( SOT_FORMATSTR_ID_HTML ) ) );
+
+ SfxBindings& rBindings = GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_PASTE );
+ rBindings.Invalidate( SID_PASTE_SPECIAL );
+ rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
+ }
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Status (Enabled/Disabled) von Menue-SfxSlots setzen
+|*
+\************************************************************************/
+
+void OutlineViewShell::GetMenuState( SfxItemSet &rSet )
+{
+ ViewShell::GetMenuState(rSet);
+
+ // Vorlagenkatalog darf nicht aufgerufen werden
+ rSet.DisableItem( SID_STYLE_CATALOG );
+
+ rSet.Put(SfxBoolItem(SID_DIAMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_DRAWINGMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_OUTLINEMODE, sal_True));
+ rSet.Put(SfxBoolItem(SID_NOTESMODE, sal_False));
+ rSet.Put(SfxBoolItem(SID_HANDOUTMODE, sal_False));
+
+ if (!mpZoomList->IsNextPossible())
+ {
+ rSet.DisableItem(SID_ZOOM_NEXT);
+ }
+ if (!mpZoomList->IsPreviousPossible())
+ {
+ rSet.DisableItem(SID_ZOOM_PREV);
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_IN ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ZOOM_OUT ) )
+ {
+ if( GetActiveWindow()->GetZoom() <= GetActiveWindow()->GetMinZoom() || GetDocSh()->IsUIActive() )
+ rSet.DisableItem( SID_ZOOM_IN );
+ if( GetActiveWindow()->GetZoom() >= GetActiveWindow()->GetMaxZoom() || GetDocSh()->IsUIActive() )
+ rSet.DisableItem( SID_ZOOM_OUT );
+ }
+
+ ::Outliner* pOutl = pOlView->GetOutliner();
+ DBG_ASSERT(pOutl, "OutlineViewShell::GetMenuState(), no outliner? Fatality!");
+ if( !pOutl )
+ return;
+
+ // 'Alles auswaehlen' zulassen?
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_SELECTALL ) )
+ {
+ sal_uLong nParaCount = pOutl->GetParagraphCount();
+ sal_Bool bDisable = nParaCount == 0;
+ if (!bDisable && nParaCount == 1)
+ {
+ String aTest( pOutl->GetText( pOutl->GetParagraph( 0 ) ) );
+ if (aTest.Len() == 0)
+ {
+ bDisable = sal_True;
+ }
+ }
+ if (bDisable)
+ rSet.DisableItem(SID_SELECTALL);
+ }
+
+ // Status des Lineals setzen
+ rSet.Put( SfxBoolItem( SID_RULER, HasRuler() ) );
+
+ // Formatierung ein oder aus?
+ rSet.Put( SfxBoolItem( SID_OUTLINE_FORMAT, !pOutl->IsFlatMode() ) );
+
+ if( pOutl->IsFlatMode() )
+ rSet.DisableItem( SID_COLORVIEW );
+ else
+ {
+ // Farbansicht ein/aus
+ sal_uLong nCntrl = pOutl->GetControlWord();
+ sal_Bool bNoColor = sal_False;
+ if (nCntrl & EE_CNTRL_NOCOLORS)
+ bNoColor = sal_True;
+
+ rSet.Put( SfxBoolItem( SID_COLORVIEW, bNoColor ) );
+ }
+
+ // Buttons der Werkzeugleiste
+ // zunaechst selektionsabhaengige: COLLAPSE, EXPAND
+ sal_Bool bDisableCollapse = sal_True;
+ sal_Bool bDisableExpand = sal_True;
+ sal_Bool bUnique = sal_True;
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow(GetActiveWindow());
+ List* pList = pOutlinerView->CreateSelectionList();
+ Paragraph* pPara = (Paragraph*)pList->First();
+
+ sal_Int16 nDepth;
+ sal_Int16 nTmpDepth = pOutl->GetDepth( (sal_uInt16) pOutl->GetAbsPos( pPara ) );
+ bool bPage = pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE );
+ while (pPara)
+ {
+ nDepth = pOutl->GetDepth( (sal_uInt16) pOutl->GetAbsPos( pPara ) );
+
+ if( nDepth != nTmpDepth )
+ bUnique = sal_False;
+ if( bPage != pOutl->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
+ bUnique = sal_False;
+ if (!pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
+ bDisableExpand = sal_False;
+ if (pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
+ bDisableCollapse = sal_False;
+
+ pPara = (Paragraph*)pList->Next();
+ }
+
+ delete pList;
+
+ if (bDisableExpand)
+ rSet.DisableItem(SID_OUTLINE_EXPAND);
+ if (bDisableCollapse)
+ rSet.DisableItem(SID_OUTLINE_COLLAPSE);
+
+ // ergibt die Selektion ein eindeutiges Praesentationslayout?
+ // wenn nicht, duerfen die Vorlagen nicht bearbeitet werden
+ SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT);
+ GetStatusBarState(aSet);
+ String aTest(((SfxStringItem&)aSet.Get(SID_STATUS_LAYOUT)).GetValue());
+ if (aTest.Len() == 0)
+ {
+ bUnique = sal_False;
+ rSet.DisableItem(SID_PRESENTATION_TEMPLATES);
+ }
+
+ if (!bUnique)
+ rSet.DisableItem( SID_PRESENTATIONOBJECT );
+
+ // jetzt die selektionsunabhaengigen: COLLAPSE_ALL, EXPAND_ALL
+ sal_Bool bDisableCollapseAll = sal_True;
+ sal_Bool bDisableExpandAll = sal_True;
+
+ // wenn schon die Selektion etwas kollabierbares/expandierbares enthaelt
+ if (!bDisableCollapse)
+ bDisableCollapseAll = sal_False;
+ if (!bDisableExpand)
+ bDisableExpandAll = sal_False;
+
+ // schade, so billig kommen wir nicht davon; alle Absaetze durchsuchen
+ if (bDisableCollapseAll || bDisableExpandAll)
+ {
+ sal_uLong nParaPos = 0;
+ pPara = pOutl->GetParagraph( nParaPos );
+ while (pPara && (bDisableCollapseAll || bDisableExpandAll))
+ {
+ if (!pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
+ bDisableExpandAll = sal_False;
+
+ if (pOutl->IsExpanded(pPara) && pOutl->HasChilds(pPara))
+ bDisableCollapseAll = sal_False;
+
+ pPara = pOutl->GetParagraph( ++nParaPos );
+ }
+ }
+
+ if (bDisableExpandAll)
+ rSet.DisableItem(SID_OUTLINE_EXPAND_ALL);
+ if (bDisableCollapseAll)
+ rSet.DisableItem(SID_OUTLINE_COLLAPSE_ALL);
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PASTE ) )
+ {
+ if ( !pClipEvtLstnr )
+ {
+ // create listener
+ pClipEvtLstnr = new TransferableClipboardListener( LINK( this, OutlineViewShell, ClipboardChanged ) );
+ pClipEvtLstnr->acquire();
+ pClipEvtLstnr->AddRemoveListener( GetActiveWindow(), sal_True );
+
+ // get initial state
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
+ bPastePossible = ( aDataHelper.GetFormatCount() != 0 &&
+ ( aDataHelper.HasFormat( FORMAT_STRING ) ||
+ aDataHelper.HasFormat( FORMAT_RTF ) ||
+ aDataHelper.HasFormat( SOT_FORMATSTR_ID_HTML ) ) );
+ }
+
+ if( !bPastePossible )
+ {
+ rSet.DisableItem( SID_PASTE );
+ }
+ }
+
+ if (!pOlView->GetViewByWindow(GetActiveWindow())->HasSelection())
+ {
+ rSet.DisableItem(SID_CUT);
+ rSet.DisableItem(SID_COPY);
+ }
+
+ if (pOlView->GetOutliner()->IsModified())
+ {
+ GetDoc()->SetChanged(sal_True);
+ }
+
+ // Da �berladen, muss hier der Status gesetzt werden
+ if( !GetDocSh()->IsModified() )
+ {
+ rSet.DisableItem( SID_SAVEDOC );
+ }
+
+ if ( GetDocSh()->IsReadOnly() )
+ {
+ rSet.DisableItem( SID_AUTOSPELL_CHECK );
+ }
+ else
+ {
+ if (GetDoc()->GetOnlineSpell())
+ {
+ rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_True));
+ }
+ else
+ {
+ rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, sal_False));
+ }
+ }
+
+ // Feldbefehle
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_MODIFY_FIELD ) )
+ {
+ const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection();
+
+ if( !( pFldItem && (pFldItem->GetField()->ISA( SvxDateField ) ||
+ pFldItem->GetField()->ISA( SvxAuthorField ) ||
+ pFldItem->GetField()->ISA( SvxExtFileField ) ||
+ pFldItem->GetField()->ISA( SvxExtTimeField ) ) ) )
+ {
+ rSet.DisableItem( SID_MODIFY_FIELD );
+ }
+ }
+
+ if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_EXPAND_PAGE))
+ {
+ sal_Bool bDisable = sal_True;
+ sal_uInt16 i = 0;
+ sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
+ pOlView->SetSelectedPages();
+
+ while (i < nCount && bDisable)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
+
+ if (pPage->IsSelected())
+ {
+ SdrObject* pObj = pPage->GetPresObj(PRESOBJ_OUTLINE);
+
+ if (pObj!=NULL )
+ {
+ if( !pObj->IsEmptyPresObj() )
+ {
+ bDisable = false;
+ }
+ else
+ {
+ // check if the object is in edit, than its temporarely not empty
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObj );
+ if( pTextObj )
+ {
+ OutlinerParaObject* pParaObj = pTextObj->GetEditOutlinerParaObject();
+ if( pParaObj )
+ {
+ delete pParaObj;
+ bDisable = false;
+ }
+ }
+ }
+ }
+ }
+
+ i++;
+ }
+
+ if (bDisable)
+ {
+ rSet.DisableItem(SID_EXPAND_PAGE);
+ }
+ }
+
+ if (SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_SUMMARY_PAGE))
+ {
+ sal_Bool bDisable = sal_True;
+ sal_uInt16 i = 0;
+ sal_uInt16 nCount = GetDoc()->GetSdPageCount(PK_STANDARD);
+ pOlView->SetSelectedPages();
+
+ while (i < nCount && bDisable)
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
+
+ if (pPage->IsSelected())
+ {
+ SdrObject* pObj = pPage->GetPresObj(PRESOBJ_TITLE);
+
+ if (pObj && !pObj->IsEmptyPresObj())
+ {
+ bDisable = sal_False;
+ }
+ }
+
+ i++;
+ }
+
+ if (bDisable)
+ {
+ rSet.DisableItem(SID_SUMMARY_PAGE);
+ }
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_THESAURUS ) )
+ {
+ if ( !pOlView->IsTextEdit() )
+ {
+ rSet.DisableItem( SID_THESAURUS );
+ }
+ else
+ {
+ LanguageType eLang = GetDoc()->GetLanguage( EE_CHAR_LANGUAGE );
+ Reference< XThesaurus > xThesaurus( LinguMgr::GetThesaurus() );
+ Locale aLocale;
+
+ SvxLanguageToLocale( aLocale, eLang );
+
+ if (!xThesaurus.is() || eLang == LANGUAGE_NONE || !xThesaurus->hasLocale(aLocale))
+ rSet.DisableItem( SID_THESAURUS );
+ }
+ }
+
+ // Starten der Praesentation moeglich?
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_PRESENTATION ) )
+ {
+ sal_Bool bDisable = sal_True;
+ sal_uInt16 nCount = GetDoc()->GetSdPageCount( PK_STANDARD );
+
+ for( sal_uInt16 i = 0; i < nCount && bDisable; i++ )
+ {
+ SdPage* pPage = GetDoc()->GetSdPage(i, PK_STANDARD);
+
+ if( !pPage->IsExcluded() )
+ bDisable = sal_False;
+ }
+ if( bDisable || GetDocSh()->IsPreview())
+ {
+ rSet.DisableItem( SID_PRESENTATION );
+ }
+ }
+
+ FuBullet::GetSlotState( rSet, this, GetViewFrame() );
+
+ //rSet.DisableItem( SID_PRINTDOC );
+ //rSet.DisableItem( SID_PRINTDOCDIRECT );
+ //rSet.DisableItem( SID_SETUPPRINTER );
+}
+
+/*************************************************************************
+|*
+|* wird gerufen, wenn ScrollBar benutzt wird
+|*
+\************************************************************************/
+
+long OutlineViewShell::VirtHScrollHdl(ScrollBar* pHScroll)
+{
+ long nThumb = pHScroll->GetThumbPos();
+ long nRange = pHScroll->GetRange().Len();
+ double fX = (double) nThumb / nRange;
+
+ Window* pWin = mpContentWindow.get();
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin);
+ long nViewWidth = pWin->PixelToLogic(
+ pWin->GetSizePixel()).Width();
+ long nTextWidth = pOlView->GetPaperWidth();
+ nViewWidth = Max(nViewWidth, nTextWidth);
+ long nCurrentPos = pOutlinerView->GetVisArea().Left();
+ long nTargetPos = (long)(fX * nViewWidth);
+ long nDelta = nTargetPos - nCurrentPos;
+
+ pOutlinerView->HideCursor();
+ pOutlinerView->Scroll(-nDelta, 0);
+ pOutlinerView->ShowCursor(sal_False);
+
+ pOlView->InvalidateSlideNumberArea();
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* wird gerufen, wenn ScrollBar benutzt wird
+|*
+\************************************************************************/
+
+long OutlineViewShell::VirtVScrollHdl(ScrollBar* pVScroll)
+{
+ long nThumb = pVScroll->GetThumbPos();
+ long nRange = pVScroll->GetRange().Len();
+ double fY = (double) nThumb / nRange;
+
+ Window* pWin = mpContentWindow.get();
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin);
+ long nViewHeight = pWin->PixelToLogic(
+ pWin->GetSizePixel()).Height();
+ long nTextHeight = pOlView->GetOutliner()->GetTextHeight();
+ nViewHeight += nTextHeight;
+ long nCurrentPos = pOutlinerView->GetVisArea().Top();
+ long nTargetPos = (long)(fY * nViewHeight);
+ long nDelta = nTargetPos - nCurrentPos;
+
+ pOutlinerView->HideCursor();
+ pOutlinerView->Scroll(0, -nDelta);
+ pOutlinerView->ShowCursor(sal_False);
+
+ pOlView->InvalidateSlideNumberArea();
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* PrepareClose, wird gerufen, wenn die Shell zestoert werden soll,
+|* leitet den Aufruf an die View weiter
+|*
+\************************************************************************/
+
+sal_uInt16 OutlineViewShell::PrepareClose( sal_Bool bUI, sal_Bool bForBrowsing )
+{
+ if( ViewShell::PrepareClose(bUI, bForBrowsing) != sal_True )
+ return sal_False;
+
+ return pOlView == NULL || pOlView->PrepareClose(bUI);
+}
+
+
+/*************************************************************************
+|*
+|* Zoomen mit Zoomfaktor, OutlinerView informieren
+|*
+\************************************************************************/
+
+void OutlineViewShell::SetZoom(long nZoom)
+{
+ ViewShell::SetZoom(nZoom);
+
+ ::sd::Window* pWindow = mpContentWindow.get();
+ if (pWindow)
+ {
+ // OutputArea der OutlinerView aendern
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
+ Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
+ aWin = pWindow->PixelToLogic(aWin);
+ pOutlinerView->SetOutputArea(aWin);
+ }
+
+ // #106268#
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
+}
+
+/*************************************************************************
+|*
+|* Zoomen mit Zoomrechteck, OutlinerView informieren
+|*
+\************************************************************************/
+
+void OutlineViewShell::SetZoomRect(const Rectangle& rZoomRect)
+{
+ ViewShell::SetZoomRect(rZoomRect);
+
+ ::sd::Window* pWindow = mpContentWindow.get();
+ if (pWindow)
+ {
+ // OutputArea der OutlinerView aendern
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
+ Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
+ aWin = pWindow->PixelToLogic(aWin);
+ pOutlinerView->SetOutputArea(aWin);
+ }
+
+ // #106268#
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
+}
+
+/*************************************************************************
+|*
+|* Vorm Speichern das Model der Drawing Engine aktualisieren, dann den
+|* Call weiterleiten an die ObjectShell.
+|*
+\************************************************************************/
+
+void OutlineViewShell::Execute(SfxRequest& rReq)
+{
+ bool bForwardCall = true;
+
+ switch(rReq.GetSlot())
+ {
+ case SID_SAVEDOC:
+ case SID_SAVEASDOC:
+ PrepareClose();
+ break;
+
+ case SID_SEARCH_ITEM:
+ // Forward this request to the the common (old) code of the
+ // document shell.
+ GetDocSh()->Execute (rReq);
+ bForwardCall = false;
+ break;
+
+ case SID_SPELL_DIALOG:
+ {
+ SfxViewFrame* pViewFrame = GetViewFrame();
+ if (rReq.GetArgs() != NULL)
+ pViewFrame->SetChildWindow (SID_SPELL_DIALOG,
+ ((const SfxBoolItem&) (rReq.GetArgs()->
+ Get(SID_SPELL_DIALOG))).GetValue());
+ else
+ pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG);
+
+ pViewFrame->GetBindings().Invalidate(SID_SPELL_DIALOG);
+ rReq.Done ();
+
+ bForwardCall = false;
+ }
+ break;
+
+ default:
+ OSL_TRACE ("OutlineViewShell::Execute(): can not handle slot %d", rReq.GetSlot());
+ break;
+
+ }
+
+ if (bForwardCall)
+ ((DrawDocShell*)GetViewFrame()->GetObjectShell())->ExecuteSlot( rReq );
+}
+
+/*************************************************************************
+|*
+|* Read FrameViews data and set actual views data
+|*
+\************************************************************************/
+
+void OutlineViewShell::ReadFrameViewData(FrameView* pView)
+{
+ ::Outliner* pOutl = pOlView->GetOutliner();
+
+ if ( pView->IsNoAttribs() )
+ pOutl->SetFlatMode( sal_True ); // Attribut-Darstellung ausschalten
+ else
+ pOutl->SetFlatMode( sal_False ); // Attribut-Darstellung einschalten
+
+ sal_uLong nCntrl = pOutl->GetControlWord();
+
+ if ( pView->IsNoColors() )
+ pOutl->SetControlWord(nCntrl | EE_CNTRL_NOCOLORS); // Farbansicht ausschalten
+ else
+ pOutl->SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS); // Farbansicht einschalten
+
+ sal_uInt16 nPage = mpFrameView->GetSelectedPage();
+ pLastPage = GetDoc()->GetSdPage( nPage, PK_STANDARD );
+ pOlView->SetActualPage(pLastPage);
+}
+
+
+
+/*************************************************************************
+|*
+|* Write actual views data to FrameView
+|*
+\************************************************************************/
+
+void OutlineViewShell::WriteFrameViewData()
+{
+ ::Outliner* pOutl = pOlView->GetOutliner();
+
+ sal_uLong nCntrl = pOutl->GetControlWord();
+ sal_Bool bNoColor = sal_False;
+ if (nCntrl & EE_CNTRL_NOCOLORS)
+ bNoColor = sal_True;
+ mpFrameView->SetNoColors(bNoColor);
+ mpFrameView->SetNoAttribs( pOutl->IsFlatMode() );
+ SdPage* pActualPage = pOlView->GetActualPage();
+ DBG_ASSERT(pActualPage, "No current page");
+ if( pActualPage )
+ mpFrameView->SetSelectedPage((pActualPage->GetPageNum() - 1) / 2);
+}
+
+
+/*************************************************************************
+|*
+|* SfxRequests fuer StatusBar bearbeiten
+|*
+\************************************************************************/
+
+void OutlineViewShell::ExecStatusBar(SfxRequest&)
+{
+}
+
+/*************************************************************************
+|*
+|* Statuswerte der Statusbar zurueckgeben
+|*
+\************************************************************************/
+
+void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet)
+{
+ // Zoom-Item
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOM ) )
+ {
+ SvxZoomItem* pZoomItem;
+ sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom();
+
+ pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom );
+
+ // Bereich einschraenken
+ sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
+ nZoomValues &= ~SVX_ZOOM_ENABLE_OPTIMAL;
+ nZoomValues &= ~SVX_ZOOM_ENABLE_WHOLEPAGE;
+ nZoomValues &= ~SVX_ZOOM_ENABLE_PAGEWIDTH;
+
+ pZoomItem->SetValueSet( nZoomValues );
+ rSet.Put( *pZoomItem );
+ delete pZoomItem;
+ }
+
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
+ {
+ if (GetDocSh()->IsUIActive() || !GetActiveWindow() )
+ {
+ rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
+ }
+ else
+ {
+ sd::Window * pActiveWindow = GetActiveWindow();
+ SvxZoomSliderItem aZoomItem( (sal_uInt16) pActiveWindow->GetZoom(), (sal_uInt16)pActiveWindow->GetMinZoom(), (sal_uInt16)pActiveWindow->GetMaxZoom() ) ;
+ aZoomItem.AddSnappingPoint(100);
+ rSet.Put( aZoomItem );
+ }
+ }
+
+
+ // Seitenanzeige und Layout
+ /*
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_PAGE ) ||
+ SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STATUS_LAYOUT ) )
+ */
+ sal_uInt16 nPageCount = GetDoc()->GetSdPageCount( PK_STANDARD );
+ String aPageStr, aLayoutStr;
+
+ ::sd::Window* pWin = GetActiveWindow();
+ OutlinerView* pActiveView = pOlView->GetViewByWindow( pWin );
+ ::Outliner* pOutliner = pOlView->GetOutliner();
+ List* pSelList = (List*)pActiveView->CreateSelectionList();
+ Paragraph* pFirstPara = (Paragraph*)pSelList->First();
+ Paragraph* pLastPara = (Paragraph*)pSelList->Last();
+
+ if( !pOutliner->HasParaFlag(pFirstPara,PARAFLAG_ISPAGE) )
+ pFirstPara = pOlView->GetPrevTitle( pFirstPara );
+
+ if( !pOutliner->HasParaFlag(pLastPara, PARAFLAG_ISPAGE) )
+ pLastPara = pOlView->GetPrevTitle( pLastPara );
+
+ delete pSelList; // die wurde extra fuer uns erzeugt
+
+ // nur eine Seite selektiert?
+ if( pFirstPara == pLastPara )
+ {
+ // wieviele Seiten sind vor der selektierten Seite?
+ sal_uLong nPos = 0L;
+ while( pFirstPara )
+ {
+ pFirstPara = pOlView->GetPrevTitle( pFirstPara );
+ if( pFirstPara )
+ nPos++;
+ }
+
+ if( nPos >= GetDoc()->GetSdPageCount( PK_STANDARD ) )
+ nPos = 0;
+
+ SdrPage* pPage = GetDoc()->GetSdPage( (sal_uInt16) nPos, PK_STANDARD );
+
+ aPageStr = String(SdResId( STR_SD_PAGE ));
+ aPageStr += sal_Unicode(' ');
+ aPageStr += String::CreateFromInt32( (sal_Int32)(nPos + 1) ); // sal_uLong -> sal_Int32
+ aPageStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " / " ));
+ aPageStr += String::CreateFromInt32( nPageCount );
+
+ aLayoutStr = pPage->GetLayoutName();
+ aLayoutStr.Erase( aLayoutStr.SearchAscii( SD_LT_SEPARATOR ) );
+ }
+ rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) );
+ rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) );
+}
+
+/*************************************************************************
+|*
+|* Command event
+|*
+\************************************************************************/
+
+void OutlineViewShell::Command( const CommandEvent& rCEvt, ::sd::Window* pWin )
+{
+ if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU )
+ {
+ GetActiveWindow()->ReleaseMouse();
+
+ OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
+ Point aPos(rCEvt.GetMousePosPixel());
+
+ if (pOLV && pOLV->IsWrongSpelledWordAtPos(aPos))
+ {
+ // #91457# Popup for Online-Spelling now handled by DrawDocShell
+ // Link aLink = LINK(GetDoc(), SdDrawDocument, OnlineSpellCallback);
+ Link aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
+
+ pOLV->ExecuteSpellPopup(aPos, &aLink);
+ }
+ else
+ {
+ GetViewFrame()->GetDispatcher()->ExecutePopup(SdResId(RID_OUTLINE_POPUP));
+ }
+ }
+ else
+ {
+ ViewShell::Command( rCEvt, pWin );
+
+ // ggfs. Preview den neuen Kontext mitteilen
+ Invalidate( SID_PREVIEW_STATE );
+
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Keyboard event
+|*
+\************************************************************************/
+
+sal_Bool OutlineViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
+{
+ sal_Bool bReturn = sal_False;
+ OutlineViewPageChangesGuard aGuard(pOlView);
+
+ if (pWin == NULL && HasCurrentFunction())
+ {
+ bReturn = GetCurrentFunction()->KeyInput(rKEvt);
+ }
+
+ // nein, weiterleiten an Basisklasse
+ else
+ {
+ bReturn = ViewShell::KeyInput(rKEvt, pWin);
+ }
+
+ Invalidate(SID_STYLE_EDIT);
+ Invalidate(SID_STYLE_NEW);
+ Invalidate(SID_STYLE_DELETE);
+ Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
+ Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
+ Invalidate(SID_STYLE_WATERCAN);
+ Invalidate(SID_STYLE_FAMILY5);
+
+ // Pruefen und Unterscheiden von CursorBewegungs- oder Eingabe-Keys
+ KeyCode aKeyGroup( rKEvt.GetKeyCode().GetGroup() );
+ if( (aKeyGroup != KEYGROUP_CURSOR && aKeyGroup != KEYGROUP_FKEYS) ||
+ (GetActualPage() != pLastPage) )
+ {
+ Invalidate( SID_PREVIEW_STATE );
+ }
+
+ return(bReturn);
+}
+
+
+/*************************************************************************
+|*
+|* Optimale Groesse zurueckgeben
+|*
+\************************************************************************/
+
+Size OutlineViewShell::GetOptimalSizePixel() const
+{
+ Size aResult(200, 200);
+ if (pOlView)
+ {
+ ::Outliner* pOutliner = pOlView->GetOutliner();
+ if (pOutliner)
+ {
+ Size aTemp = pOutliner->CalcTextSize();
+ aTemp = GetActiveWindow()->LogicToPixel(aTemp);
+ aResult.Width() = Max(aResult.Width(), aTemp.Width());
+ aResult.Height() = Max(aResult.Height(), aTemp.Height());
+ if (4 * aResult.Height() > 3 * aResult.Width())
+ {
+ aResult.Height() = 3 * aResult.Width() / 4;
+ }
+ }
+ }
+
+ // und jetzt jetzt das Standardgelumpe draufaddieren
+ aResult.Width() += mpVerticalScrollBar->GetSizePixel().Width();
+ aResult.Height() += mpHorizontalScrollBar->GetSizePixel().Height();
+ //!!! + System::GetMenuBarHeightPixel(); // statt Titlebar
+ return aResult;
+}
+
+
+/*************************************************************************
+|*
+|* Text der Selektion zurueckgeben
+|*
+\************************************************************************/
+
+String OutlineViewShell::GetSelectionText(sal_Bool bCompleteWords)
+{
+ String aStrSelection;
+ ::Outliner* pOl = pOlView->GetOutliner();
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
+
+ if (pOl && pOlView)
+ {
+ if (bCompleteWords)
+ {
+ ESelection aSel = pOutlinerView->GetSelection();
+ String aStrCurrentDelimiters = pOl->GetWordDelimiters();
+
+ pOl->SetWordDelimiters( String( RTL_CONSTASCII_USTRINGPARAM( " .,;\"'" )));
+ aStrSelection = pOl->GetWord( aSel.nEndPara, aSel.nEndPos );
+ pOl->SetWordDelimiters( aStrCurrentDelimiters );
+ }
+ else
+ {
+ aStrSelection = pOutlinerView->GetSelected();
+ }
+ }
+
+ return (aStrSelection);
+}
+
+
+/*************************************************************************
+|*
+|* Ist etwas selektiert?
+|*
+\************************************************************************/
+
+sal_Bool OutlineViewShell::HasSelection(sal_Bool bText) const
+{
+ sal_Bool bReturn = sal_False;
+
+ if (bText)
+ {
+ OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
+
+ if (pOutlinerView && pOutlinerView->GetSelected().Len() != 0)
+ {
+ bReturn = sal_True;
+ }
+ }
+
+ return bReturn;
+}
+
+
+/*************************************************************************
+|*
+|* Status der Attribut-Items
+|*
+\************************************************************************/
+
+void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
+{
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ SfxAllItemSet aAllSet( *rSet.GetPool() );
+
+ while ( nWhich )
+ {
+ sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
+ ? GetPool().GetSlotId(nWhich)
+ : nWhich;
+
+ switch ( nSlotId )
+ {
+ case SID_STYLE_FAMILY2:
+ case SID_STYLE_FAMILY3:
+ {
+ rSet.DisableItem( nWhich );
+ }
+ break;
+
+ case SID_STYLE_FAMILY5:
+ {
+ SfxStyleSheet* pStyleSheet = pOlView->GetViewByWindow(GetActiveWindow())->GetStyleSheet();
+
+ if( pStyleSheet )
+ {
+ pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
+
+ if (pStyleSheet)
+ {
+ SfxTemplateItem aItem( nWhich, pStyleSheet->GetName() );
+ aAllSet.Put( aItem, aItem.Which() );
+ }
+ }
+
+ if( !pStyleSheet )
+ {
+ SfxTemplateItem aItem( nWhich, String() );
+ aAllSet.Put( aItem, aItem.Which() );
+ // rSet.DisableItem( nWhich );
+ }
+ }
+ break;
+
+ case SID_STYLE_EDIT:
+ {
+ ISfxTemplateCommon* pTmplCommon = SFX_APP()->GetCurrentTemplateCommon(GetViewFrame()->GetBindings());
+
+ if (pTmplCommon && pTmplCommon->GetActualFamily() == SD_STYLE_FAMILY_PSEUDO)
+ {
+ SfxItemSet aSet(*rSet.GetPool(), SID_STATUS_LAYOUT, SID_STATUS_LAYOUT);
+ GetStatusBarState(aSet);
+ String aRealStyle(((SfxStringItem&) aSet.Get(SID_STATUS_LAYOUT)).GetValue());
+
+ if (!aRealStyle.Len())
+ {
+ // Kein eindeutiger Layoutname gefunden
+ rSet.DisableItem(nWhich);
+ }
+ }
+ }
+ break;
+
+ case SID_STYLE_UPDATE_BY_EXAMPLE:
+ {
+ ::sd::Window* pActWin = GetActiveWindow();
+ OutlinerView* pOV = pOlView->GetViewByWindow(pActWin);
+ ESelection aESel(pOV->GetSelection());
+
+ if (aESel.nStartPara != aESel.nEndPara ||
+ aESel.nStartPos != aESel.nEndPos)
+ // aufgespannte Selektion, also StyleSheet und/oder
+ // Attributierung nicht zwingend eindeutig
+ rSet.DisableItem(nWhich);
+ }
+ break;
+
+ case SID_STYLE_NEW:
+ case SID_STYLE_DELETE:
+ case SID_STYLE_NEW_BY_EXAMPLE:
+ case SID_STYLE_WATERCAN:
+ {
+ rSet.DisableItem(nWhich);
+ }
+ break;
+ }
+
+ nWhich = aIter.NextWhich();
+ }
+
+ rSet.Put( aAllSet, sal_False );
+}
+
+
+
+/*************************************************************************
+|*
+|* MouseButtonUp event
+|*
+\************************************************************************/
+
+void OutlineViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
+{
+ // Zuerst die Basisklasse
+ ViewShell::MouseButtonUp(rMEvt, pWin);
+
+ Invalidate(SID_STYLE_EDIT);
+ Invalidate(SID_STYLE_NEW);
+ Invalidate(SID_STYLE_DELETE);
+ Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
+ Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
+ Invalidate(SID_STYLE_WATERCAN);
+ Invalidate(SID_STYLE_FAMILY5);
+
+ // ggfs. Preview den neuen Kontext mitteilen
+ if( GetActualPage() != pLastPage )
+ Invalidate( SID_PREVIEW_STATE );
+}
+
+
+
+SdPage* OutlineViewShell::getCurrentPage() const
+{
+ // since there are no master pages in outline view, we can
+ // for now use the GetActualPage method
+ return const_cast<OutlineViewShell*>(this)->GetActualPage();
+}
+
+/*************************************************************************
+|*
+|* Liefert die erste selektierte Seite zurueck.
+|* Wenn nichts selektiert ist, wird die erste Seite zurueckgeliefert.
+|*
+\************************************************************************/
+SdPage* OutlineViewShell::GetActualPage()
+{
+ return pOlView->GetActualPage();
+}
+
+
+void OutlineViewShell::UpdatePreview( SdPage* pPage, sal_Bool )
+{
+ const bool bNewPage = pPage != pLastPage;
+ pLastPage = pPage;
+ if (bNewPage)
+ {
+ OutlineViewPageChangesGuard aGuard(pOlView);
+ SetCurrentPage(pPage);
+ }
+}
+
+/*************************************************************************
+|*
+|* Update Title
+|*
+\************************************************************************/
+
+bool OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph* pPara )
+{
+ DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateTitleObject(), pPage == 0?" );
+ DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateTitleObject(), pPara == 0?" );
+
+ if( !pPage || !pPara )
+ return false;
+
+ ::Outliner* pOutliner = pOlView->GetOutliner();
+ SdrTextObj* pTO = pOlView->GetTitleTextObject( pPage );
+ OutlinerParaObject* pOPO = NULL;
+
+ String aTest( pOutliner->GetText( pPara ) );
+ bool bText = aTest.Len() > 0;
+ bool bNewObject = false;
+
+ if( bText )
+ {
+ // create a title object if we don't have one but have text
+ if( !pTO )
+ {
+ DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
+ pTO = pOlView->CreateTitleTextObject(pPage);
+ bNewObject = sal_True;
+ }
+
+ // if we have a title object and a text, set the text
+ if( pTO )
+ {
+ pOPO = pOutliner->CreateParaObject( (sal_uInt16) pOutliner->GetAbsPos( pPara ), 1 );
+ pOPO->SetOutlinerMode( OUTLINERMODE_TITLEOBJECT );
+ pOPO->SetVertical( pTO->IsVerticalWriting() );
+ if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
+ {
+ // do nothing, same text already set
+ delete pOPO;
+ }
+ else
+ {
+ DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
+ if( !bNewObject && pOlView->isRecordingUndo() )
+ pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
+
+ pTO->SetOutlinerParaObject( pOPO );
+ pTO->SetEmptyPresObj( sal_False );
+ pTO->ActionChanged();
+ }
+ }
+ }
+ else if( pTO )
+ {
+ // no text but object available?
+ // outline object available, but we have no text
+ if(pPage->IsPresObj(pTO))
+ {
+ // if it is not already empty
+ if( !pTO->IsEmptyPresObj() )
+ {
+ DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
+
+ // make it empty
+ if( pOlView->isRecordingUndo() )
+ pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
+ pPage->RestoreDefaultText( pTO );
+ pTO->SetEmptyPresObj(sal_True);
+ pTO->ActionChanged();
+ }
+ }
+ else
+ {
+ DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
+ // outline object is not part of the layout, delete it
+ if( pOlView->isRecordingUndo() )
+ pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
+ pPage->RemoveObject(pTO->GetOrdNum());
+ }
+ }
+
+ return bNewObject;
+}
+
+/*************************************************************************
+|*
+|* Update LayoutObject
+|*
+\************************************************************************/
+
+bool OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara )
+{
+ DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateOutlineObject(), pPage == 0?" );
+ DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateOutlineObject(), pPara == 0?" );
+
+ if( !pPage || !pPara )
+ return false;
+
+ ::Outliner* pOutliner = pOlView->GetOutliner();
+ OutlinerParaObject* pOPO = NULL;
+ SdrTextObj* pTO = NULL;
+
+ sal_Bool bNewObject = sal_False;
+
+ sal_uInt16 eOutlinerMode = OUTLINERMODE_TITLEOBJECT;
+ pTO = (SdrTextObj*)pPage->GetPresObj( PRESOBJ_TEXT );
+ if( !pTO )
+ {
+ eOutlinerMode = OUTLINERMODE_OUTLINEOBJECT;
+ pTO = pOlView->GetOutlineTextObject( pPage );
+ }
+
+ // wieviele Absaetze in der Gliederung?
+ sal_uLong nTitlePara = pOutliner->GetAbsPos( pPara );
+ sal_uLong nPara = nTitlePara + 1;
+ sal_uLong nParasInLayout = 0L;
+ pPara = pOutliner->GetParagraph( nPara );
+ while( pPara && !pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
+ {
+ nParasInLayout++;
+ pPara = pOutliner->GetParagraph( ++nPara );
+ }
+ if( nParasInLayout )
+ {
+ // ein OutlinerParaObject erzeugen
+ pPara = pOutliner->GetParagraph( nTitlePara + 1 );
+ pOPO = pOutliner->CreateParaObject( (sal_uInt16) nTitlePara + 1, (sal_uInt16) nParasInLayout );
+ }
+
+ if( pOPO )
+ {
+ DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
+
+ // do we need an outline text object?
+ if( !pTO )
+ {
+ pTO = pOlView->CreateOutlineTextObject( pPage );
+ bNewObject = sal_True;
+ }
+
+ // Seitenobjekt, Gliederungstext im Outliner:
+ // Text uebernehmen
+ if( pTO )
+ {
+ pOPO->SetVertical( pTO->IsVerticalWriting() );
+ pOPO->SetOutlinerMode( eOutlinerMode );
+ if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
+ {
+ // do nothing, same text already set
+ delete pOPO;
+ }
+ else
+ {
+ if( !bNewObject && pOlView->isRecordingUndo() )
+ pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
+
+ pTO->SetOutlinerParaObject( pOPO );
+ pTO->SetEmptyPresObj( sal_False );
+ pTO->ActionChanged();
+ }
+ }
+ }
+ else if( pTO )
+ {
+ // Seitenobjekt, aber kein Gliederungstext:
+ // wenn Objekt in Praesentationsliste der Seite ist -> Defaulttext,
+ // sonst Objekt loeschen
+ if( pPage->IsPresObj(pTO) )
+ {
+ if( !pTO->IsEmptyPresObj() )
+ {
+ DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
+
+ // loescht auch altes OutlinerParaObject
+ if( pOlView->isRecordingUndo() )
+ pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
+ pPage->RestoreDefaultText( pTO );
+ pTO->SetEmptyPresObj(sal_True);
+ pTO->ActionChanged();
+ }
+ }
+ else
+ {
+ DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
+ if( pOlView->isRecordingUndo() )
+ pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
+ pPage->RemoveObject(pTO->GetOrdNum());
+ }
+ }
+
+ return bNewObject;
+}
+
+
+/*************************************************************************
+|*
+|* Outliner aus Stream fuellen
+|*
+\************************************************************************/
+
+sal_uLong OutlineViewShell::Read(SvStream& rInput, const String& rBaseURL, sal_uInt16 eFormat)
+{
+ sal_uLong bRet = 0;
+
+ ::Outliner* pOutl = pOlView->GetOutliner();
+
+ {
+ OutlineViewPageChangesGuard aGuard( pOlView );
+ OutlineViewModelChangeGuard aGuard2( *pOlView );
+
+ bRet = pOutl->Read( rInput, rBaseURL, eFormat, GetDocSh()->GetHeaderAttributes() );
+
+ SdPage* pPage = GetDoc()->GetSdPage( GetDoc()->GetSdPageCount(PK_STANDARD) - 1, PK_STANDARD );;
+ SfxStyleSheet* pTitleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
+ SfxStyleSheet* pOutlSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
+
+ sal_uInt16 nParaCount = (sal_uInt16)pOutl->GetParagraphCount();
+ if ( nParaCount > 0 )
+ {
+ for ( sal_uInt16 nPara = 0; nPara < nParaCount; nPara++ )
+ {
+ pOlView->UpdateParagraph( nPara );
+
+ sal_Int16 nDepth = pOutl->GetDepth( nPara );
+
+ if( (nDepth == 0) || !nPara )
+ {
+ Paragraph* pPara = pOutl->GetParagraph( nPara );
+ pOutl->SetDepth(pPara, -1);
+ pOutl->SetParaFlag(pPara, PARAFLAG_ISPAGE);
+
+ pOutl->SetStyleSheet( nPara, pTitleSheet );
+
+ if( nPara ) // first slide already exists
+ pOlView->InsertSlideForParagraph( pPara );
+ }
+ else
+ {
+ pOutl->SetDepth( pOutl->GetParagraph( nPara ), nDepth - 1 );
+ String aStyleSheetName( pOutlSheet->GetName() );
+ aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
+ aStyleSheetName += String::CreateFromInt32( nDepth );
+ SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
+ SfxStyleSheet* pStyle = (SfxStyleSheet*) pStylePool->Find( aStyleSheetName, pOutlSheet->GetFamily() );
+ DBG_ASSERT( pStyle, "AutoStyleSheetName - Style not found!" );
+ if ( pStyle )
+ pOutl->SetStyleSheet( nPara, pStyle );
+ }
+ }
+ }
+ }
+
+ pOutl->GetUndoManager().Clear();
+
+ return( bRet );
+}
+
+void OutlineViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ WriteFrameViewData();
+
+ ViewShell::WriteUserDataSequence( rSequence, bBrowse );
+}
+
+void OutlineViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ WriteFrameViewData();
+
+ ViewShell::ReadUserDataSequence( rSequence, bBrowse );
+
+ ReadFrameViewData( mpFrameView );
+}
+
+void OutlineViewShell::VisAreaChanged(const Rectangle& rRect)
+{
+ ViewShell::VisAreaChanged( rRect );
+
+ GetViewShellBase().GetDrawController().FireVisAreaChanged(rRect);
+}
+
+/** If there is a valid controller then create a new instance of
+ <type>AccessibleDrawDocumentView</type>. Otherwise delegate this call
+ to the base class to return a default object (probably an empty
+ reference).
+*/
+::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ OutlineViewShell::CreateAccessibleDocumentView (::sd::Window* pWindow)
+{
+ OSL_ASSERT (GetViewShell()!=NULL);
+ if (GetViewShell()->GetController() != NULL)
+ {
+ ::accessibility::AccessibleOutlineView* pDocumentView =
+ new ::accessibility::AccessibleOutlineView (
+ pWindow,
+ this,
+ GetViewShell()->GetController(),
+ pWindow->GetAccessibleParentWindow()->GetAccessible());
+ pDocumentView->Init();
+ return ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ (static_cast< ::com::sun::star::uno::XWeak*>(pDocumentView),
+ ::com::sun::star::uno::UNO_QUERY);
+ }
+ else
+ {
+ OSL_TRACE ("OutlineViewShell::CreateAccessibleDocumentView: no controller");
+ return ViewShell::CreateAccessibleDocumentView (pWindow);
+ }
+}
+
+
+
+
+void OutlineViewShell::GetState (SfxItemSet& rSet)
+{
+ // Iterate over all requested items in the set.
+ SfxWhichIter aIter( rSet );
+ sal_uInt16 nWhich = aIter.FirstWhich();
+ while (nWhich)
+ {
+ switch (nWhich)
+ {
+ case SID_SEARCH_ITEM:
+ case SID_SEARCH_OPTIONS:
+ // Call common (old) implementation in the document shell.
+ GetDocSh()->GetState (rSet);
+ break;
+ default:
+ OSL_TRACE ("OutlineViewShell::GetState(): can not handle which id %d", nWhich);
+ break;
+ }
+ nWhich = aIter.NextWhich();
+ }
+}
+
+
+
+
+void OutlineViewShell::SetCurrentPage (SdPage* pPage)
+{
+ // Adapt the selection of the model.
+ for (sal_uInt16 i=0; i<GetDoc()->GetSdPageCount(PK_STANDARD); i++)
+ GetDoc()->SetSelected(
+ GetDoc()->GetSdPage(i, PK_STANDARD),
+ sal_False);
+ GetDoc()->SetSelected (pPage, sal_True);
+
+ DrawController& rController(GetViewShellBase().GetDrawController());
+ rController.FireSelectionChangeListener();
+ rController.FireSwitchCurrentPage (pPage);
+
+ pOlView->SetActualPage(pPage);
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx
new file mode 100755
index 000000000000..020ecf11b42f
--- /dev/null
+++ b/sd/source/ui/view/outlview.cxx
@@ -0,0 +1,2181 @@
+/*************************************************************************
+ *
+ * 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 "OutlineView.hxx"
+#include <memory>
+#include <editeng/forbiddencharacterstable.hxx>
+#include <sfx2/progress.hxx>
+#include <vcl/wrkwin.hxx>
+#include <svx/svxids.hrc>
+#include "eetext.hxx"
+#include <editeng/eeitem.hxx>
+#include <editeng/editstat.hxx>
+#include <editeng/lrspitem.hxx>
+#include <svx/svdotext.hxx>
+#include <sfx2/printer.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/bindings.hxx>
+#include <svl/itempool.hxx>
+#include <svl/style.hxx>
+#include <svx/svdorect.hxx>
+#include <svx/svdundo.hxx>
+#include <svl/brdcst.hxx>
+#include <vcl/msgbox.hxx>
+#include <editeng/adjitem.hxx>
+#include <editeng/tstpitem.hxx>
+#include <editeng/lspcitem.hxx>
+#include <editeng/numitem.hxx>
+#include <editeng/outlobj.hxx>
+#include <editeng/numitem.hxx>
+#include <editeng/editeng.hxx>
+
+// #97766#
+#include <editeng/editobj.hxx>
+#include <editeng/editund2.hxx>
+
+#include <editeng/editview.hxx>
+#include <editeng/svxfont.hxx>
+#include <editeng/fhgtitem.hxx>
+
+#include "DrawDocShell.hxx"
+#include "drawdoc.hxx"
+#include "Window.hxx"
+#include "sdpage.hxx"
+#include "pres.hxx"
+#include "OutlineViewShell.hxx"
+#include "app.hrc"
+#include "glob.hrc"
+#include "sdresid.hxx"
+#include "Outliner.hxx"
+#include "strings.hrc"
+#include "EventMultiplexer.hxx"
+#include "ViewShellBase.hxx"
+#include "undo/undoobjects.hxx"
+#include "undo/undomanager.hxx"
+#include "stlsheet.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+
+namespace sd {
+
+// Breite: DIN A 4, zwei Raender zu je 1 cm
+#define OUTLINE_PAPERWIDTH 19000
+
+// beim Seitenmanipulation Fortschrittsanzeige, wenn mehr Seiten betroffen
+// sind als:
+#define PROCESS_WITH_PROGRESS_THRESHOLD 5
+
+struct SdParaAndPos
+{
+ Paragraph* pPara;
+ sal_uInt16 nPos;
+};
+
+TYPEINIT1( OutlineView, ::sd::View );
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+OutlineView::OutlineView( DrawDocShell* pDocSh, ::Window* pWindow, OutlineViewShell* pOutlineViewSh)
+: ::sd::View(pDocSh->GetDoc(), pWindow, pOutlineViewSh)
+, mpOutlineViewShell(pOutlineViewSh)
+, mpOutliner( mpDoc->GetOutliner(sal_True) )
+, mpOldParaOrder(NULL)
+, mpSelectedParas(NULL)
+, mnPagesToProcess(0)
+, mnPagesProcessed(0)
+, mbFirstPaint(sal_True)
+, mpProgress(NULL)
+, mbHighContrastMode( false )
+, maDocColor( COL_WHITE )
+, mnPageNumberWidthPixel( 0 )
+, maLRSpaceItem( 0, 0, 2000, 0, EE_PARA_OUTLLRSPACE )
+{
+ sal_Bool bInitOutliner = sal_False;
+
+ if (mpOutliner->GetViewCount() == 0)
+ {
+ // Outliner initialisieren: Referenz-Device setzen
+ bInitOutliner = sal_True;
+ mpOutliner->Init( OUTLINERMODE_OUTLINEVIEW );
+/*
+ SfxStyleSheet* pTitleSheet = mpDoc->GetSdPage( 0, PK_STANDARD )->GetStyleSheetForPresObj( PRESOBJ_TITLE );
+
+ if ( pTitleSheet )
+ {
+ // set title symbol (level 0)
+ SvxNumBulletItem aNumBulletItem( (const SvxNumBulletItem&) pTitleSheet->GetItemSet().Get(EE_PARA_NUMBULLET) );
+ SvxNumRule aNumRule(* aNumBulletItem.GetNumRule());
+ SvxNumberFormat aFormat( aNumRule.GetLevel(0));
+ Font aBulletFont;
+ const Font* pFont = aFormat.GetBulletFont();
+ if ( pFont ) // if available take font size and color from style
+ aBulletFont = *pFont;
+ else
+ {
+ aBulletFont.SetColor( COL_AUTO );
+ aBulletFont.SetHeight( 1552 );
+ }
+ aBulletFont.SetCharSet(RTL_TEXTENCODING_MS_1252); // and replacing other values by standard
+ aBulletFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "StarSymbol" )) );
+ aBulletFont.SetWeight(WEIGHT_NORMAL);
+ aBulletFont.SetUnderline(UNDERLINE_NONE);
+ aBulletFont.SetStrikeout(STRIKEOUT_NONE);
+ aBulletFont.SetItalic(ITALIC_NONE);
+ aBulletFont.SetOutline(sal_False);
+ aBulletFont.SetShadow(sal_False);
+ aFormat.SetBulletFont( &aBulletFont );
+ aFormat.SetBulletChar( 0xE011 ); // StarBats: 0xF000 + 114
+ mpOutliner->OverwriteLevel0Bullet( aFormat );
+ }
+*/
+ mpOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *pDocSh ) );
+ sal_uLong nWidth = OUTLINE_PAPERWIDTH;
+ mpOutliner->SetPaperSize(Size(nWidth, 400000000));
+ }
+
+ // View in Outliner einfuegen
+ for (sal_uInt16 nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
+ {
+ mpOutlinerView[nView] = NULL;
+ }
+
+ mpOutlinerView[0] = new OutlinerView(mpOutliner, pWindow);
+ Rectangle aNullRect;
+ mpOutlinerView[0]->SetOutputArea(aNullRect);
+ mpOutliner->SetUpdateMode(sal_False);
+ mpOutliner->InsertView(mpOutlinerView[0], LIST_APPEND);
+
+ onUpdateStyleSettings( true );
+
+ if (bInitOutliner)
+ {
+ // Outliner mit Inhalt fuellen
+ FillOutliner();
+ }
+
+ Link aLink( LINK(this,OutlineView,EventMultiplexerListener) );
+ mpOutlineViewShell->GetViewShellBase().GetEventMultiplexer()->AddEventListener(
+ aLink,
+ tools::EventMultiplexerEvent::EID_CURRENT_PAGE
+ | tools::EventMultiplexerEvent::EID_PAGE_ORDER);
+
+ LanguageType eLang = mpOutliner->GetDefaultLanguage();
+ maPageNumberFont = OutputDevice::GetDefaultFont( DEFAULTFONT_SANS_UNICODE, eLang, 0 );
+ maPageNumberFont.SetHeight( 500 );
+
+ maBulletFont.SetColor( COL_AUTO );
+ maBulletFont.SetHeight( 1000 );
+ maBulletFont.SetCharSet(RTL_TEXTENCODING_MS_1252); // and replacing other values by standard
+ maBulletFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "StarSymbol" )) );
+ maBulletFont.SetWeight(WEIGHT_NORMAL);
+ maBulletFont.SetUnderline(UNDERLINE_NONE);
+ maBulletFont.SetStrikeout(STRIKEOUT_NONE);
+ maBulletFont.SetItalic(ITALIC_NONE);
+ maBulletFont.SetOutline(sal_False);
+ maBulletFont.SetShadow(sal_False);
+
+
+ Reference<XFrame> xFrame (mpOutlineViewShell->GetViewShellBase().GetFrame()->GetTopFrame().GetFrameInterface(), UNO_QUERY);
+
+ const OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( ".uno:ShowSlide" ));
+ maSlideImage = GetImage( xFrame, aSlotURL, true, false /* todo, hc mode */ );
+
+ // Tell undo manager of the document about the undo manager of the
+ // outliner, so that the former can synchronize with the later.
+ sd::UndoManager* pDocUndoMgr = dynamic_cast<sd::UndoManager*>(mpDocSh->GetUndoManager());
+ if (pDocUndoMgr != NULL)
+ pDocUndoMgr->SetLinkedUndoManager(&mpOutliner->GetUndoManager());
+}
+
+/*************************************************************************
+|*
+|* Destruktor, Links restaurieren, Outliner leeren
+|*
+\************************************************************************/
+
+OutlineView::~OutlineView()
+{
+ DBG_ASSERT(maDragAndDropModelGuard.get() == 0, "sd::OutlineView::~OutlineView(), prior drag operation not finished correctly!" );
+
+ Link aLink( LINK(this,OutlineView,EventMultiplexerListener) );
+ mpOutlineViewShell->GetViewShellBase().GetEventMultiplexer()->RemoveEventListener( aLink );
+ DisconnectFromApplication();
+
+ if( mpProgress )
+ delete mpProgress;
+
+ // OutlinerViews abmelden und zerstoeren
+ for (sal_uInt16 nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
+ {
+ if (mpOutlinerView[nView] != NULL)
+ {
+ mpOutliner->RemoveView( mpOutlinerView[nView] );
+ delete mpOutlinerView[nView];
+ mpOutlinerView[nView] = NULL;
+ }
+ }
+
+ if (mpOutliner->GetViewCount() == 0)
+ {
+ // Outliner deinitialisieren: Farbdarstellung einschalten
+ ResetLinks();
+ sal_uLong nCntrl = mpOutliner->GetControlWord();
+ mpOutliner->SetUpdateMode(sal_False); // sonst wird bei SetControlWord gezeichnet
+ mpOutliner->SetControlWord(nCntrl & ~EE_CNTRL_NOCOLORS);
+ SvtAccessibilityOptions aOptions;
+ mpOutliner->ForceAutoColor( aOptions.GetIsAutomaticFontColor() );
+ mpOutliner->Clear();
+ }
+
+ DBG_ASSERT(!mpSelectedParas, "Absatzliste nicht geloescht");
+ DBG_ASSERT(!mpOldParaOrder, "Absatzliste nicht geloescht");
+}
+
+
+
+
+void OutlineView::ConnectToApplication (void)
+{
+ mpOutlineViewShell->GetActiveWindow()->GrabFocus();
+ Application::AddEventListener(LINK(this, OutlineView, AppEventListenerHdl));
+}
+
+
+
+
+void OutlineView::DisconnectFromApplication (void)
+{
+ Application::RemoveEventListener(LINK(this, OutlineView, AppEventListenerHdl));
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Paint-Methode
+|*
+\************************************************************************/
+
+void OutlineView::Paint(const Rectangle& rRect, ::sd::Window* pWin)
+{
+ OutlinerView* pOlView = GetViewByWindow(pWin);
+
+ if (pOlView)
+ {
+ pOlView->HideCursor();
+ pOlView->Paint(rRect);
+
+ pOlView->ShowCursor(mbFirstPaint);
+
+/*
+ if( mnPageNumberWidthPixel == 0 )
+ GetPageNumberWidthPixel();
+
+ const sal_uLong nParaCount = pOlView->GetOutliner()->GetParagraphCount();
+ EditView& rEditView = pOlView->GetEditView();
+
+ Font aOldFont( pWin->GetFont() );
+
+ const String aBulletStr( sal_Unicode( 0xE011 ) );
+ pWin->SetFont( maBulletFont);
+ sal_Int32 nBulletWidth = pWin->GetTextWidth(aBulletStr);
+
+ sal_Int32 nPage = 1;
+ for( sal_uLong nPara = 0; nPara < nParaCount; nPara++ )
+ {
+ Paragraph* pPara = pOlView->GetOutliner()->GetParagraph( nPara );
+ if( pPara->HasFlag( PARAFLAG_ISPAGE ) )
+ {
+ pWin->SetFont( maPageNumberFont );
+ const String aStr( String::CreateFromInt32( nPage++ ) );
+ Point aPos( rEditView.GetWindowPosTopLeft( (sal_uInt16)nPara ) );
+
+ sal_Int32 nNumberOffset = pWin->PixelToLogic( Point(mnPageNumberWidthPixel, 0) ).X() - nBulletWidth;
+ sal_Int32 nLineHeight = pOlView->GetOutliner()->GetLineHeight( nPara, 0 );
+
+ aPos.X() = nNumberOffset;
+
+ Point aPoint( aPos.X() - pWin->GetTextWidth( aStr ), aPos.Y() + ( nLineHeight - maPageNumberFont.GetHeight()) / 2 );
+ pWin->DrawText( aPoint, aStr );
+
+ aPoint.X() = aPos.X();
+ aPoint.Y() = aPos.Y() +( nLineHeight - maBulletFont.GetHeight()) / 2;
+ pWin->SetFont( maBulletFont );
+ pWin->DrawText( aPoint, aBulletStr );
+ }
+ }
+
+ pWin->SetFont( aOldFont );
+*/
+ mbFirstPaint = sal_False;
+ }
+}
+
+void OutlineView::InvalidateSlideNumberArea()
+{
+/*
+ for( sal_Int16 nView = 0; nView < MAX_OUTLINERVIEWS; ++nView )
+ {
+ if (mpOutlinerView[nView] != NULL)
+ {
+ ::Window* pWindow = mpOutlinerView[nView]->GetWindow();
+ if( pWindow )
+ {
+ Rectangle aRect( Point(0,0), pWindow->GetOutputSize() );
+ aRect.nRight = aRect.nLeft + pWindow->PixelToLogic( Point( mnPageNumberWidthPixel, 0 ) ).X() * 2;
+
+ pWindow->Invalidate(aRect);
+ }
+ }
+ }
+*/
+}
+
+/*************************************************************************
+|*
+|* Fenster-Groesse hat sich geaendert
+|*
+\************************************************************************/
+
+void OutlineView::AdjustPosSizePixel(const Point &,const Size &,::sd::Window*)
+{
+}
+
+/*************************************************************************
+|*
+|* ein Fenster hinzufuegen
+|*
+\************************************************************************/
+
+void OutlineView::AddWindowToPaintView(OutputDevice* pWin)
+{
+ sal_Bool bAdded = sal_False;
+ sal_Bool bValidArea = sal_False;
+ Rectangle aOutputArea;
+ const Color aWhiteColor( COL_WHITE );
+ sal_uInt16 nView = 0;
+
+ while (nView < MAX_OUTLINERVIEWS && !bAdded)
+ {
+ if (mpOutlinerView[nView] == NULL)
+ {
+ mpOutlinerView[nView] = new OutlinerView(mpOutliner, dynamic_cast< ::sd::Window* >(pWin));
+ mpOutlinerView[nView]->SetBackgroundColor( aWhiteColor );
+ mpOutliner->InsertView(mpOutlinerView[nView], LIST_APPEND);
+ bAdded = sal_True;
+
+ if (bValidArea)
+ {
+ mpOutlinerView[nView]->SetOutputArea(aOutputArea);
+ }
+ }
+ else if (!bValidArea)
+ {
+ aOutputArea = mpOutlinerView[nView]->GetOutputArea();
+ bValidArea = sal_True;
+ }
+
+ nView++;
+ }
+
+ // weisser Hintergrund im Outliner
+ pWin->SetBackground( Wallpaper( aWhiteColor ) );
+
+ ::sd::View::AddWindowToPaintView(pWin);
+}
+
+/*************************************************************************
+|*
+|* ein Fenster entfernen
+|*
+\************************************************************************/
+
+void OutlineView::DeleteWindowFromPaintView(OutputDevice* pWin)
+{
+ sal_Bool bRemoved = sal_False;
+ sal_uInt16 nView = 0;
+ ::Window* pWindow;
+
+ while (nView < MAX_OUTLINERVIEWS && !bRemoved)
+ {
+ if (mpOutlinerView[nView] != NULL)
+ {
+ pWindow = mpOutlinerView[nView]->GetWindow();
+
+ if (pWindow == pWin)
+ {
+ mpOutliner->RemoveView( mpOutlinerView[nView] );
+ delete mpOutlinerView[nView];
+ mpOutlinerView[nView] = NULL;
+ bRemoved = sal_True;
+ }
+ }
+
+ nView++;
+ }
+
+ ::sd::View::DeleteWindowFromPaintView(pWin);
+}
+
+/*************************************************************************
+|*
+|* Zeiger der dem Fenster entsprechenden OutlinerView zurueckgeben.
+|*
+\************************************************************************/
+
+OutlinerView* OutlineView::GetViewByWindow (::Window* pWin) const
+{
+ OutlinerView* pOlView = NULL;
+ for (sal_uInt16 nView = 0; nView < MAX_OUTLINERVIEWS; nView++)
+ {
+ if (mpOutlinerView[nView] != NULL)
+ {
+ if ( pWin == mpOutlinerView[nView]->GetWindow() )
+ {
+ pOlView = mpOutlinerView[nView];
+ }
+ }
+ }
+ return (pOlView);
+}
+
+
+/*************************************************************************
+|*
+|* Ermittelt den Titel vor einem beliebigen Absatz.
+|*
+\************************************************************************/
+
+Paragraph* OutlineView::GetPrevTitle(const Paragraph* pPara)
+{
+ sal_Int32 nPos = mpOutliner->GetAbsPos(const_cast<Paragraph*>(pPara));
+
+ if (nPos > 0)
+ {
+ while(nPos)
+ {
+ pPara = mpOutliner->GetParagraph(--nPos);
+ if( mpOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
+ {
+ return const_cast< Paragraph* >( pPara );
+ }
+ }
+
+ }
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* Ermittelt den Titel nach einem beliebigen Absatz.
+|*
+\************************************************************************/
+
+Paragraph* OutlineView::GetNextTitle(const Paragraph* pPara)
+{
+ Paragraph* pResult = const_cast< Paragraph* >( pPara );
+
+ sal_Int32 nPos = mpOutliner->GetAbsPos(pResult);
+
+ do
+ {
+ pResult = mpOutliner->GetParagraph(++nPos);
+ if( pResult && mpOutliner->HasParaFlag(pResult, PARAFLAG_ISPAGE) )
+ return pResult;
+ }
+ while( pResult );
+
+ return NULL;
+}
+
+/*************************************************************************
+|*
+|* Handler fuer das Einfuegen von Seiten (Absaetzen)
+|*
+\************************************************************************/
+
+IMPL_LINK( OutlineView, ParagraphInsertedHdl, ::Outliner *, pOutliner )
+{
+// DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::ParagraphInsertedHdl(), model change without undo?!" );
+
+ // we get calls to this handler during binary insert of drag and drop contents but
+ // we ignore it here and handle it later in OnEndPasteOrDrop()
+ if( maDragAndDropModelGuard.get() == 0 )
+ {
+ OutlineViewPageChangesGuard aGuard(this);
+
+ Paragraph* pPara = pOutliner->GetHdlParagraph();
+
+ sal_uInt16 nAbsPos = (sal_uInt16)mpOutliner->GetAbsPos( pPara );
+
+ UpdateParagraph( nAbsPos );
+
+ if( (nAbsPos == 0) || mpOutliner->HasParaFlag(pPara,PARAFLAG_ISPAGE) || mpOutliner->HasParaFlag(mpOutliner->GetParagraph( nAbsPos-1 ), PARAFLAG_ISPAGE) )
+ {
+ InsertSlideForParagraph( pPara );
+ InvalidateSlideNumberArea();
+ }
+ }
+
+ return 0;
+}
+
+/** creates and inserts an empty slide for the given paragraph */
+SdPage* OutlineView::InsertSlideForParagraph( Paragraph* pPara )
+{
+ DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::InsertSlideForParagraph(), model change without undo?!" );
+
+ OutlineViewPageChangesGuard aGuard(this);
+
+ mpOutliner->SetParaFlag( pPara, PARAFLAG_ISPAGE );
+ // wieviele Titel sind vor dem neuen Titelabsatz?
+ sal_uLong nExample = 0L; // Position der "Vorbild"seite
+ sal_uLong nTarget = 0L; // Einfuegeposition
+ while(pPara)
+ {
+ pPara = GetPrevTitle(pPara);
+ if (pPara)
+ nTarget++;
+ }
+
+
+ // was der Outliner nicht kann, muss hier wieder wettgemacht werden:
+ // wenn VOR dem ersten Absatz ein neuer Absatz mit RETURN erzeugt wird,
+ // meldet der Outliner den bereits bestehenden (jetzt nach unten
+ // gerutschten) Absatz als neuen Absatz; nicht darauf reinfallen!
+ if (nTarget == 1)
+ {
+ String aTest(mpOutliner->GetText( mpOutliner->GetParagraph( 0 ) ));
+ if (aTest.Len() == 0)
+ {
+ nTarget = 0;
+ }
+ }
+
+
+ // "Vorbild"seite ist - wenn vorhanden - die Vorgaengerseite
+ if (nTarget > 0)
+ {
+ nExample = nTarget - 1;
+
+ sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
+ if( nExample >= nPageCount )
+ nExample = nPageCount - 1;
+ }
+
+ /**********************************************************************
+ * Es wird stets zuerst eine Standardseite und dann eine
+ * Notizseite erzeugt. Es ist sichergestellt, dass auf eine
+ * Standardseite stets die zugehoerige Notizseite folgt.
+ * Vorangestellt ist genau eine Handzettelseite
+ **********************************************************************/
+
+ // diese Seite hat Vorbildfunktion
+ SdPage* pExample = (SdPage*)mpDoc->GetSdPage((sal_uInt16)nExample, PK_STANDARD);
+ SdPage* pPage = (SdPage*)mpDoc->AllocPage(sal_False);
+
+ pPage->SetLayoutName(pExample->GetLayoutName());
+
+ // einfuegen (Seite)
+ mpDoc->InsertPage(pPage, (sal_uInt16)(nTarget) * 2 + 1);
+ if( isRecordingUndo() )
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pPage));
+
+ // der Standardseite eine Masterpage zuweisen
+ pPage->TRG_SetMasterPage(pExample->TRG_GetMasterPage());
+
+ // Seitengroesse setzen
+ pPage->SetSize(pExample->GetSize());
+ pPage->SetBorder( pExample->GetLftBorder(),
+ pExample->GetUppBorder(),
+ pExample->GetRgtBorder(),
+ pExample->GetLwrBorder() );
+
+ // neue Praesentationsobjekte anlegen (auf <Titel> oder
+ // <Titel mit Untertitel> folgt <Titel mit Gliederung>, ansonsten
+ // wird das Layout von der Vorgaengerseite uebernommen)
+ AutoLayout eAutoLayout = pExample->GetAutoLayout();
+ if (eAutoLayout == AUTOLAYOUT_TITLE ||
+ eAutoLayout == AUTOLAYOUT_ONLY_TITLE)
+ {
+ pPage->SetAutoLayout(AUTOLAYOUT_ENUM, sal_True);
+ }
+ else
+ {
+ pPage->SetAutoLayout(pExample->GetAutoLayout(), sal_True);
+ }
+
+ /**********************************************************************
+ |* jetzt die Notizseite
+ \*********************************************************************/
+ pExample = (SdPage*)mpDoc->GetSdPage((sal_uInt16)nExample, PK_NOTES);
+ SdPage* pNotesPage = (SdPage*)mpDoc->AllocPage(sal_False);
+
+ pNotesPage->SetLayoutName(pExample->GetLayoutName());
+
+ pNotesPage->SetPageKind(PK_NOTES);
+
+ // einfuegen (Notizseite)
+ mpDoc->InsertPage(pNotesPage, (sal_uInt16)(nTarget) * 2 + 2);
+ if( isRecordingUndo() )
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewPage(*pNotesPage));
+
+ // der Notizseite eine Masterpage zuweisen
+ pNotesPage->TRG_SetMasterPage(pExample->TRG_GetMasterPage());
+
+ // Seitengroesse setzen, es muss bereits eine Seite vorhanden sein
+ pNotesPage->SetSize(pExample->GetSize());
+ pNotesPage->SetBorder( pExample->GetLftBorder(),
+ pExample->GetUppBorder(),
+ pExample->GetRgtBorder(),
+ pExample->GetLwrBorder() );
+
+ // neue Praesentationsobjekte anlegen
+ pNotesPage->SetAutoLayout(pExample->GetAutoLayout(), sal_True);
+
+ mpOutliner->UpdateFields();
+
+ return pPage;
+}
+
+/*************************************************************************
+|*
+|* Handler fuer das Loeschen von Seiten (Absaetzen)
+|*
+\************************************************************************/
+
+IMPL_LINK( OutlineView, ParagraphRemovingHdl, ::Outliner *, pOutliner )
+{
+ DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::ParagraphRemovingHdl(), model change without undo?!" );
+
+ OutlineViewPageChangesGuard aGuard(this);
+
+ Paragraph* pPara = pOutliner->GetHdlParagraph();
+ if( pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) )
+ {
+ // wieviele Titel sind vor dem fraglichen Titelabsatz?
+ sal_uLong nPos = 0L;
+ while(pPara)
+ {
+ pPara = GetPrevTitle(pPara);
+ if (pPara) nPos++;
+ }
+
+ // Seite und Notizseite loeschen
+ sal_uInt16 nAbsPos = (sal_uInt16)nPos * 2 + 1;
+ SdrPage* pPage = mpDoc->GetPage(nAbsPos);
+ if( isRecordingUndo() )
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
+ mpDoc->RemovePage(nAbsPos);
+
+ nAbsPos = (sal_uInt16)nPos * 2 + 1;
+ pPage = mpDoc->GetPage(nAbsPos);
+ if( isRecordingUndo() )
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
+ mpDoc->RemovePage(nAbsPos);
+
+ // ggfs. Fortschrittsanzeige
+ if (mnPagesToProcess)
+ {
+ mnPagesProcessed++;
+
+ if(mpProgress)
+ mpProgress->SetState(mnPagesProcessed);
+
+ if (mnPagesProcessed == mnPagesToProcess)
+ {
+ if(mpProgress)
+ {
+ delete mpProgress;
+ mpProgress = NULL;
+ }
+ mnPagesToProcess = 0;
+ mnPagesProcessed = 0;
+ }
+ }
+ pOutliner->UpdateFields();
+ }
+
+ InvalidateSlideNumberArea();
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Handler fuer das Aendern der Einruecktiefe von Absaetzen (macht ggfs.
+|* das Einfuegen oder Loeschen von Seiten notwendig)
+|*
+\************************************************************************/
+
+IMPL_LINK( OutlineView, DepthChangedHdl, ::Outliner *, pOutliner )
+{
+ DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::DepthChangedHdl(), no undo for model change?!" );
+
+ OutlineViewPageChangesGuard aGuard(this);
+
+ Paragraph* pPara = pOutliner->GetHdlParagraph();
+ if( pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && ((pOutliner->GetPrevFlags() & PARAFLAG_ISPAGE) == 0) )
+ {
+ // the current paragraph is transformed into a slide
+
+ mpOutliner->SetDepth( pPara, -1 );
+
+ // werden da etwa mehrere Level-1-Absaetze auf Level 0 gebracht und
+ // wir sollten eine Fortschrittsanzeige oder Eieruhr aufsetzen und
+ // haben es noch nicht getan?
+ if (mnPagesToProcess == 0)
+ {
+ Window* pActWin = mpOutlineViewShell->GetActiveWindow();
+ OutlinerView* pOlView = GetViewByWindow(pActWin);
+ List* pList = pOlView->CreateSelectionList();
+
+ Paragraph* pParagraph = (Paragraph*)pList->First();
+ while (pParagraph)
+ {
+ if( !pOutliner->HasParaFlag( pParagraph, PARAFLAG_ISPAGE ) && (pOutliner->GetDepth( (sal_uInt16) pOutliner->GetAbsPos( pParagraph ) ) <= 0) )
+ mnPagesToProcess++;
+ pParagraph = (Paragraph*)pList->Next();
+ }
+
+ mnPagesToProcess++; // der Absatz, der jetzt schon auf Level 0
+ // steht, gehoert auch dazu
+ mnPagesProcessed = 0;
+
+ if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD)
+ {
+ if( mpProgress )
+ delete mpProgress;
+
+ const String aStr(SdResId(STR_CREATE_PAGES));
+ mpProgress = new SfxProgress( GetDocSh(), aStr, mnPagesToProcess );
+ }
+ else
+ {
+ mpDocSh->SetWaitCursor( sal_True );
+ }
+ delete pList;
+ }
+
+ ParagraphInsertedHdl(pOutliner);
+
+ mnPagesProcessed++;
+
+ // muss eine Fortschrittsanzeige gepflegt werden?
+ if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD)
+ {
+ if (mpProgress)
+ mpProgress->SetState(mnPagesProcessed);
+ }
+
+ // war das die letzte Seite?
+ if (mnPagesProcessed == mnPagesToProcess)
+ {
+ if (mnPagesToProcess > PROCESS_WITH_PROGRESS_THRESHOLD && mpProgress)
+ {
+ delete mpProgress;
+ mpProgress = NULL;
+ }
+ else
+ mpDocSh->SetWaitCursor( sal_False );
+
+ mnPagesToProcess = 0;
+ mnPagesProcessed = 0;
+ }
+ pOutliner->UpdateFields();
+ }
+ else if( !pOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE ) && ((pOutliner->GetPrevFlags() & PARAFLAG_ISPAGE) != 0) )
+ {
+ // the paragraph was a page but now becomes a normal paragraph
+
+ // how many titles are before the title paragraph in question?
+ sal_uLong nPos = 0L;
+ Paragraph* pParagraph = pPara;
+ while(pParagraph)
+ {
+ pParagraph = GetPrevTitle(pParagraph);
+ if (pParagraph)
+ nPos++;
+ }
+ // Seite und Notizseite loeschen
+
+ sal_uInt16 nAbsPos = (sal_uInt16)nPos * 2 + 1;
+ SdrPage* pPage = mpDoc->GetPage(nAbsPos);
+ if( isRecordingUndo() )
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
+ mpDoc->RemovePage(nAbsPos);
+
+ nAbsPos = (sal_uInt16)nPos * 2 + 1;
+ pPage = mpDoc->GetPage(nAbsPos);
+ if( isRecordingUndo() )
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
+ mpDoc->RemovePage(nAbsPos);
+
+ pPage = GetPageForParagraph( pPara );
+
+ mpOutliner->SetDepth( pPara, (pPage && (static_cast<SdPage*>(pPage)->GetAutoLayout() == AUTOLAYOUT_TITLE)) ? -1 : 0 );
+
+ // ggfs. Fortschrittsanzeige
+ if (mnPagesToProcess)
+ {
+ mnPagesProcessed++;
+ if (mpProgress)
+ mpProgress->SetState(mnPagesProcessed);
+
+ if (mnPagesProcessed == mnPagesToProcess)
+ {
+ if(mpProgress)
+ {
+ delete mpProgress;
+ mpProgress = NULL;
+ }
+ mnPagesToProcess = 0;
+ mnPagesProcessed = 0;
+ }
+ }
+ pOutliner->UpdateFields();
+ }
+ else if ( (pOutliner->GetPrevDepth() == 1) && ( pOutliner->GetDepth( (sal_uInt16) pOutliner->GetAbsPos( pPara ) ) == 2 ) )
+ {
+ // wieviele Titel sind vor dem fraglichen Titelabsatz?
+ sal_Int32 nPos = -1L;
+
+ Paragraph* pParagraph = pPara;
+ while(pParagraph)
+ {
+ pParagraph = GetPrevTitle(pParagraph);
+ if (pParagraph)
+ nPos++;
+ }
+
+ if(nPos >= 0)
+ {
+ SdPage*pPage = (SdPage*)mpDoc->GetSdPage( (sal_uInt16) nPos, PK_STANDARD);
+
+ if(pPage && pPage->GetPresObj(PRESOBJ_TEXT))
+ pOutliner->SetDepth( pPara, 0 );
+ }
+
+ }
+ // wieviele Titel sind vor dem fraglichen Titelabsatz?
+ sal_Int32 nPos = -1L;
+
+ Paragraph* pTempPara = pPara;
+ while(pTempPara)
+ {
+ pTempPara = GetPrevTitle(pTempPara);
+ if (pTempPara)
+ nPos++;
+ }
+
+ if( nPos >= 0 )
+ {
+ SdPage* pPage = (SdPage*) mpDoc->GetSdPage( (sal_uInt16) nPos, PK_STANDARD );
+
+ if( pPage )
+ {
+ SfxStyleSheet* pStyleSheet = NULL;
+ sal_uLong nPara = pOutliner->GetAbsPos( pPara );
+ sal_Int16 nDepth = pOutliner->GetDepth( (sal_uInt16) nPara );
+ bool bSubTitle = pPage->GetPresObj(PRESOBJ_TEXT) != NULL;
+
+ if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
+ {
+ pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE );
+ }
+ else if( bSubTitle )
+ {
+ pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_TEXT );
+ }
+ else
+ {
+ pStyleSheet = pPage->GetStyleSheetForPresObj( PRESOBJ_OUTLINE );
+
+ if( nDepth > 0 )
+ {
+ String aNewStyleSheetName( pStyleSheet->GetName() );
+ aNewStyleSheetName.Erase( aNewStyleSheetName.Len()-1, 1 );
+ aNewStyleSheetName += String::CreateFromInt32( nDepth+1 );
+ SfxStyleSheetBasePool* pStylePool = mpDoc->GetStyleSheetPool();
+ pStyleSheet = (SfxStyleSheet*) pStylePool->Find( aNewStyleSheetName, pStyleSheet->GetFamily() );
+ }
+ }
+
+ // before we set the style sheet we need to preserve the bullet item
+ // since all items will be deleted while setting a new style sheet
+ SfxItemSet aOldAttrs( pOutliner->GetParaAttribs( (sal_uInt16)nPara ) );
+
+ pOutliner->SetStyleSheet( nPara, pStyleSheet );
+
+ // restore the old bullet item but not if the style changed
+ if ( pOutliner->GetPrevDepth() != -1 && nDepth != -1 &&
+ aOldAttrs.GetItemState( EE_PARA_NUMBULLET ) == SFX_ITEM_ON )
+ {
+ SfxItemSet aAttrs( pOutliner->GetParaAttribs( (sal_uInt16)nPara ) );
+ aAttrs.Put( *aOldAttrs.GetItem( EE_PARA_NUMBULLET ) );
+ pOutliner->SetParaAttribs( (sal_uInt16)nPara, aAttrs );
+ }
+ }
+ }
+
+ InvalidateSlideNumberArea();
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Handler fuer StatusEvents
+|*
+\************************************************************************/
+
+IMPL_LINK( OutlineView, StatusEventHdl, EditStatus *, EMPTYARG )
+{
+ ::sd::Window* pWin = mpOutlineViewShell->GetActiveWindow();
+ OutlinerView* pOutlinerView = GetViewByWindow(pWin);
+ Rectangle aVis = pOutlinerView->GetVisArea();
+
+// sal_uLong nWidth = ((SdPage*)mpDoc->GetSdPage(0, PK_STANDARD))->GetSize().Width();
+ sal_uLong nWidth = OUTLINE_PAPERWIDTH;
+ Rectangle aText = Rectangle(Point(0,0),
+ Size(nWidth,
+ mpOutliner->GetTextHeight()));
+ Rectangle aWin(Point(0,0), pWin->GetOutputSizePixel());
+ aWin = pWin->PixelToLogic(aWin);
+
+ if (!aVis.IsEmpty()) // nicht beim Oeffnen
+ {
+ aText.Bottom() += aWin.GetHeight();
+
+ mpOutlineViewShell->InitWindows(Point(0,0), aText.GetSize(),
+ Point(aVis.TopLeft()));
+ mpOutlineViewShell->UpdateScrollBars();
+ }
+
+ InvalidateSlideNumberArea();
+ return 0;
+}
+
+IMPL_LINK( OutlineView, BeginDropHdl, void *, EMPTYARG )
+{
+ DBG_ASSERT(maDragAndDropModelGuard.get() == 0, "sd::OutlineView::BeginDropHdl(), prior drag operation not finished correctly!" );
+
+ maDragAndDropModelGuard.reset( new OutlineViewModelChangeGuard( *this ) );
+ return 0;
+}
+
+IMPL_LINK( OutlineView, EndDropHdl, void *, EMPTYARG )
+{
+ maDragAndDropModelGuard.reset(0);
+ InvalidateSlideNumberArea();
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Handler fuer den Beginn einer Absatzverschiebung
+|*
+\************************************************************************/
+
+IMPL_LINK( OutlineView, BeginMovingHdl, ::Outliner *, pOutliner )
+{
+ DBG_ASSERT(!mpSelectedParas, "Absatzliste nicht geloescht");
+ DBG_ASSERT(!mpOldParaOrder, "Absatzliste nicht geloescht");
+
+ OutlineViewPageChangesGuard aGuard(this);
+
+ mpOldParaOrder = new List;
+
+ // Liste der selektierten Titelabsaetze
+ mpSelectedParas = mpOutlinerView[0]->CreateSelectionList();
+ Paragraph* pPara = static_cast<Paragraph*>(mpSelectedParas->First());
+ while (pPara)
+ {
+ if( !pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
+ {
+ mpSelectedParas->Remove();
+ pPara = static_cast<Paragraph*>(mpSelectedParas->GetCurObject());
+ }
+ else
+ {
+ pPara = static_cast<Paragraph*>(mpSelectedParas->Next());
+ }
+ }
+
+ // Die zu den selektierten Absaetzen auf Ebene 0 gehoerenden Seiten
+ // selektieren
+ sal_uInt16 nPos = 0;
+ sal_uLong nParaPos = 0;
+ pPara = pOutliner->GetParagraph( 0 );
+
+ while(pPara)
+ {
+ if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) ) // eine Seite?
+ {
+ mpOldParaOrder->Insert(pPara, LIST_APPEND);
+ SdPage* pPage = mpDoc->GetSdPage(nPos, PK_STANDARD);
+ pPage->SetSelected(sal_False);
+ if (mpSelectedParas->Seek(pPara)) // selektiert?
+ {
+ pPage->SetSelected(sal_True);
+ }
+ nPos++;
+ }
+ pPara = pOutliner->GetParagraph( ++nParaPos );
+ }
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Handler fuer das Ende einer Absatzverschiebung
+|*
+\************************************************************************/
+
+IMPL_LINK( OutlineView, EndMovingHdl, ::Outliner *, pOutliner )
+{
+ OutlineViewPageChangesGuard aGuard(this);
+
+ DBG_ASSERT(mpSelectedParas, "keine Absatzliste");
+ DBG_ASSERT(mpOldParaOrder, "keine Absatzliste");
+ DBG_ASSERT( isRecordingUndo(), "sd::OutlineView::EndMovingHdl(), model change without undo?!" );
+
+ // Einfuegeposition anhand des ersten Absatzes suchen
+ Paragraph* pSearchIt = (Paragraph*)mpSelectedParas->First();
+
+ // den ersten der selektierten Paragraphen in der neuen Ordnung suchen
+ sal_uInt16 nPosNewOrder = 0;
+ sal_uLong nParaPos = 0;
+ Paragraph* pPara = pOutliner->GetParagraph( 0 );
+ Paragraph* pPrev = NULL;
+ while (pPara && pPara != pSearchIt)
+ {
+ if( pOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
+ {
+ nPosNewOrder++;
+ pPrev = pPara;
+ }
+ pPara = pOutliner->GetParagraph( ++nParaPos );
+ }
+
+ sal_uInt16 nPos = nPosNewOrder; // nPosNewOrder nicht veraendern
+ if (nPos == 0)
+ {
+ nPos = (sal_uInt16)-1; // vor der ersten Seite einfuegen
+ }
+ else
+ {
+ // den Vorgaenger in der alten Ordnung suchen
+ nPos = (sal_uInt16)mpOldParaOrder->GetPos(pPrev);
+ DBG_ASSERT(nPos != 0xffff, "Absatz nicht gefunden");
+ }
+
+ mpDoc->MovePages(nPos);
+
+ // die Seiten wieder deselektieren
+ sal_uInt16 nPageCount = (sal_uInt16)mpSelectedParas->Count();
+ while (nPageCount)
+ {
+ SdPage* pPage = mpDoc->GetSdPage(nPosNewOrder, PK_STANDARD);
+ pPage->SetSelected(sal_False);
+ nPosNewOrder++;
+ nPageCount--;
+ }
+
+ pOutliner->UpdateFields();
+
+ delete mpSelectedParas;
+ mpSelectedParas = NULL;
+ delete mpOldParaOrder;
+ mpOldParaOrder = NULL;
+
+ InvalidateSlideNumberArea();
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Eine Seite des Models nach dem Titeltextobjekt durchsuchen
+|*
+\************************************************************************/
+
+SdrTextObj* OutlineView::GetTitleTextObject(SdrPage* pPage)
+{
+ sal_uLong nObjectCount = pPage->GetObjCount();
+ SdrObject* pObject = NULL;
+ SdrTextObj* pResult = NULL;
+
+ for (sal_uLong nObject = 0; nObject < nObjectCount; nObject++)
+ {
+ pObject = pPage->GetObj(nObject);
+ if (pObject->GetObjInventor() == SdrInventor &&
+ pObject->GetObjIdentifier() == OBJ_TITLETEXT)
+ {
+ pResult = (SdrTextObj*)pObject;
+ break;
+ }
+ }
+ return pResult;
+}
+
+
+/*************************************************************************
+|*
+|* Eine Seite des Models nach dem Gliederungstextobjekt durchsuchen
+|*
+\************************************************************************/
+
+SdrTextObj* OutlineView::GetOutlineTextObject(SdrPage* pPage)
+{
+ sal_uLong nObjectCount = pPage->GetObjCount();
+ SdrObject* pObject = NULL;
+ SdrTextObj* pResult = NULL;
+
+ for (sal_uLong nObject = 0; nObject < nObjectCount; nObject++)
+ {
+ pObject = pPage->GetObj(nObject);
+ if (pObject->GetObjInventor() == SdrInventor &&
+ pObject->GetObjIdentifier() == OBJ_OUTLINETEXT)
+ {
+ pResult = (SdrTextObj*)pObject;
+ break;
+ }
+ }
+ return pResult;
+}
+
+SdrTextObj* OutlineView::CreateTitleTextObject(SdPage* pPage)
+{
+ DBG_ASSERT( GetTitleTextObject(pPage) == 0, "sd::OutlineView::CreateTitleTextObject(), there is already a title text object!" );
+
+ if( pPage->GetAutoLayout() == AUTOLAYOUT_NONE )
+ {
+ // simple case
+ pPage->SetAutoLayout( AUTOLAYOUT_ONLY_TITLE, true );
+ }
+ else
+ {
+ // we already have a layout with a title but the title
+ // object was deleted, create a new one
+ pPage->InsertAutoLayoutShape( 0, PRESOBJ_TITLE, false, pPage->GetTitleRect(), true );
+ }
+
+ return GetTitleTextObject(pPage);
+}
+
+SdrTextObj* OutlineView::CreateOutlineTextObject(SdPage* pPage)
+{
+ DBG_ASSERT( GetOutlineTextObject(pPage) == 0, "sd::OutlineView::CreateOutlineTextObject(), there is already a layout text object!" );
+
+ AutoLayout eNewLayout = pPage->GetAutoLayout();
+ switch( eNewLayout )
+ {
+ case AUTOLAYOUT_NONE:
+ case AUTOLAYOUT_ONLY_TITLE:
+ case AUTOLAYOUT_TITLE: eNewLayout = AUTOLAYOUT_ENUM; break;
+
+ case AUTOLAYOUT_CHART: eNewLayout = AUTOLAYOUT_CHARTTEXT; break;
+
+ case AUTOLAYOUT_ORG:
+ case AUTOLAYOUT_TAB:
+ case AUTOLAYOUT_OBJ: eNewLayout = AUTOLAYOUT_OBJTEXT; break;
+ default:
+ break;
+ }
+
+ if( eNewLayout != pPage->GetAutoLayout() )
+ {
+ pPage->SetAutoLayout( eNewLayout, true );
+ }
+ else
+ {
+ // we already have a layout with a text but the text
+ // object was deleted, create a new one
+ pPage->InsertAutoLayoutShape( 0,
+ (eNewLayout == AUTOLAYOUT_TITLE) ? PRESOBJ_TEXT : PRESOBJ_OUTLINE,
+ false, pPage->GetLayoutRect(), true );
+ }
+
+ return GetOutlineTextObject(pPage);
+}
+
+/** updates draw model with all changes from outliner model */
+sal_Bool OutlineView::PrepareClose(sal_Bool)
+{
+ ::sd::UndoManager* pDocUndoMgr = dynamic_cast<sd::UndoManager*>(mpDocSh->GetUndoManager());
+ if (pDocUndoMgr != NULL)
+ pDocUndoMgr->SetLinkedUndoManager(NULL);
+
+ mpOutliner->GetUndoManager().Clear();
+
+ const String aUndoStr(SdResId(STR_UNDO_CHANGE_TITLE_AND_LAYOUT));
+ BegUndo(aUndoStr);
+ UpdateDocument();
+ EndUndo();
+ mpDoc->SetSelected(GetActualPage(), sal_True);
+ return sal_True;
+}
+
+
+/*************************************************************************
+|*
+|* Attribute des selektierten Textes setzen
+|*
+\************************************************************************/
+
+sal_Bool OutlineView::SetAttributes(const SfxItemSet& rSet, sal_Bool )
+{
+ sal_Bool bOk = sal_False;
+
+ OutlinerView* pOlView = GetViewByWindow(mpOutlineViewShell->GetActiveWindow());
+
+ if (pOlView)
+ {
+ pOlView->SetAttribs(rSet);
+ bOk = sal_True;
+ }
+
+ mpOutlineViewShell->Invalidate (SID_PREVIEW_STATE);
+
+ return (bOk);
+}
+
+/*************************************************************************
+|*
+|* Attribute des selektierten Textes erfragen
+|*
+\************************************************************************/
+
+sal_Bool OutlineView::GetAttributes( SfxItemSet& rTargetSet, sal_Bool ) const
+{
+ OutlinerView* pOlView = GetViewByWindow(
+ mpOutlineViewShell->GetActiveWindow());
+ DBG_ASSERT(pOlView, "keine OutlinerView gefunden");
+
+ rTargetSet.Put( pOlView->GetAttribs(), sal_False );
+ return sal_True;
+}
+
+/** creates outliner model from draw model */
+void OutlineView::FillOutliner()
+{
+ mpOutliner->GetUndoManager().Clear();
+ mpOutliner->EnableUndo(sal_False);
+ ResetLinks();
+ mpOutliner->SetUpdateMode(false);
+
+ Paragraph* pTitleToSelect = NULL;
+ sal_uLong nPageCount = mpDoc->GetSdPageCount(PK_STANDARD);
+
+ // fill outliner with paragraphs from slides title & (outlines|subtitles)
+ for (sal_uInt16 nPage = 0; nPage < nPageCount; nPage++)
+ {
+ SdPage* pPage = (SdPage*)mpDoc->GetSdPage(nPage, PK_STANDARD);
+ Paragraph * pPara = NULL;
+
+ // take text from title shape
+ SdrTextObj* pTO = GetTitleTextObject(pPage);
+ if(pTO && !(pTO->IsEmptyPresObj()))
+ {
+ OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
+ if (pOPO)
+ {
+ sal_Bool bVertical = pOPO->IsVertical();
+ pOPO->SetVertical( sal_False );
+ mpOutliner->AddText(*pOPO);
+ pOPO->SetVertical( bVertical );
+ pPara = mpOutliner->GetParagraph( mpOutliner->GetParagraphCount()-1 );
+ }
+ }
+
+ if( pPara == 0 ) // no title, insert an empty paragraph
+ {
+ pPara = mpOutliner->Insert(String());
+ mpOutliner->SetDepth(pPara, -1);
+
+ // Keine harten Attribute vom vorherigen Absatz uebernehmen
+ mpOutliner->SetParaAttribs( (sal_uInt16)mpOutliner->GetAbsPos(pPara),
+ mpOutliner->GetEmptyItemSet() );
+
+ mpOutliner->SetStyleSheet( mpOutliner->GetAbsPos( pPara ), pPage->GetStyleSheetForPresObj( PRESOBJ_TITLE ) );
+ }
+
+ mpOutliner->SetParaFlag( pPara, PARAFLAG_ISPAGE );
+
+ sal_uLong nPara = mpOutliner->GetAbsPos( pPara );
+
+ UpdateParagraph( (sal_uInt16)nPara );
+
+ // remember paragraph of currently selected page
+ if (pPage->IsSelected())
+ pTitleToSelect = pPara;
+
+ // take text from subtitle or outline
+ pTO = static_cast<SdrTextObj*>(pPage->GetPresObj(PRESOBJ_TEXT));
+ const bool bSubTitle = pTO != 0;
+
+ if (!pTO) // if no subtile found, try outline
+ pTO = GetOutlineTextObject(pPage);
+
+ if(pTO && !(pTO->IsEmptyPresObj())) // found some text
+ {
+ OutlinerParaObject* pOPO = pTO->GetOutlinerParaObject();
+ if (pOPO)
+ {
+ sal_uInt16 nParaCount1 = (sal_uInt16)mpOutliner->GetParagraphCount();
+ sal_Bool bVertical = pOPO->IsVertical();
+ pOPO->SetVertical( sal_False );
+ mpOutliner->AddText(*pOPO);
+ pOPO->SetVertical( bVertical );
+
+ sal_uInt16 nParaCount2 = (sal_uInt16)mpOutliner->GetParagraphCount();
+ for (sal_uInt16 n = nParaCount1; n < nParaCount2; n++)
+ {
+ if( bSubTitle )
+ {
+ Paragraph* p = mpOutliner->GetParagraph(n);
+ if(p && mpOutliner->GetDepth( n ) > 0 )
+ mpOutliner->SetDepth(p, 0);
+ }
+
+ UpdateParagraph( n );
+ }
+ }
+ }
+ }
+
+ // place cursor at the start
+ Paragraph* pFirstPara = mpOutliner->GetParagraph( 0 );
+ mpOutlinerView[0]->Select( pFirstPara, sal_True, sal_False );
+ mpOutlinerView[0]->Select( pFirstPara, sal_False, sal_False );
+
+ // select title of slide that was selected
+ if (pTitleToSelect)
+ mpOutlinerView[0]->Select(pTitleToSelect, sal_True, sal_False);
+
+ SetLinks();
+
+ mpOutliner->EnableUndo(sal_True);
+
+ mpOutliner->SetUpdateMode(true);
+}
+
+/*************************************************************************
+|*
+|* Handler fuer das Loeschen von Level-0-Absaetzen (Seiten): Warnung
+|*
+\************************************************************************/
+
+IMPL_LINK( OutlineView, RemovingPagesHdl, OutlinerView *, EMPTYARG )
+{
+ sal_uInt16 nNumOfPages = mpOutliner->GetSelPageCount();
+
+ if (nNumOfPages > PROCESS_WITH_PROGRESS_THRESHOLD)
+ {
+ mnPagesToProcess = nNumOfPages;
+ mnPagesProcessed = 0;
+ }
+
+ if (mnPagesToProcess)
+ {
+ if( mpProgress )
+ delete mpProgress;
+
+ String aStr(SdResId(STR_DELETE_PAGES));
+ mpProgress = new SfxProgress( GetDocSh(), aStr, mnPagesToProcess );
+ }
+ mpOutliner->UpdateFields();
+
+ InvalidateSlideNumberArea();
+
+ return 1;
+}
+
+/*************************************************************************
+|*
+|* Handler fuer das Einruecken von Level-0-Absaetzen (Seiten): Warnung
+|*
+\************************************************************************/
+
+IMPL_LINK_INLINE_START( OutlineView, IndentingPagesHdl, OutlinerView *, pOutlinerView )
+{
+ return RemovingPagesHdl(pOutlinerView);
+}
+IMPL_LINK_INLINE_END( OutlineView, IndentingPagesHdl, OutlinerView *, pOutlinerView )
+
+
+/** returns the first slide that is selected in the outliner or where
+ the cursor is located */
+SdPage* OutlineView::GetActualPage()
+{
+ ::sd::Window* pWin = mpOutlineViewShell->GetActiveWindow();
+ OutlinerView* pActiveView = GetViewByWindow(pWin);
+ std::auto_ptr<List> pSelList( static_cast< List* >(pActiveView->CreateSelectionList()) );
+
+ SdPage* pCurrent = GetPageForParagraph(static_cast<Paragraph*>(pSelList->First()) );
+ DBG_ASSERT( pCurrent ||
+ (mpDocSh->GetUndoManager() && static_cast< sd::UndoManager *>(mpDocSh->GetUndoManager())->IsDoing()) ||
+ maDragAndDropModelGuard.get(),
+ "sd::OutlineView::GetActualPage(), no current page?" );
+ if( pCurrent )
+ return pCurrent;
+ else
+ return mpDoc->GetSdPage( 0, PK_STANDARD );
+}
+
+SdPage* OutlineView::GetPageForParagraph( Paragraph* pPara )
+{
+ if( !mpOutliner->HasParaFlag(pPara,PARAFLAG_ISPAGE) )
+ pPara = GetPrevTitle(pPara);
+
+ sal_uInt32 nPageToSelect = 0;
+ while(pPara)
+ {
+ pPara = GetPrevTitle(pPara);
+ if(pPara)
+ nPageToSelect++;
+ }
+
+ if( nPageToSelect < (sal_uInt32)mpDoc->GetSdPageCount( PK_STANDARD ) )
+ return static_cast< SdPage* >( mpDoc->GetSdPage( (sal_uInt16)nPageToSelect, PK_STANDARD) );
+ else
+ return 0;
+}
+
+Paragraph* OutlineView::GetParagraphForPage( ::Outliner* pOutl, SdPage* pPage )
+{
+ // get the number of paragraphs with ident 0 we need to skip before
+ // we finde the actual page
+ sal_uInt32 nPagesToSkip = (pPage->GetPageNum() - 1) >> 1;
+
+ sal_uInt32 nParaPos = 0;
+ Paragraph* pPara = pOutl->GetParagraph( 0 );
+ while( pPara )
+ {
+ // if this paragraph is a page ...
+ if( mpOutliner->HasParaFlag(pPara,PARAFLAG_ISPAGE) )
+ {
+ // see if we already skiped enough pages
+ if( 0 == nPagesToSkip )
+ break; // and if so, end the loop
+
+ // we skiped another page
+ nPagesToSkip--;
+ }
+
+ // get next paragraph
+ pPara = mpOutliner->GetParagraph( ++nParaPos );
+ }
+
+ return pPara;
+}
+
+/** selects the paragraph for the given page at the outliner view*/
+void OutlineView::SetActualPage( SdPage* pActual )
+{
+ if( pActual && mpOutliner && dynamic_cast<Outliner*> ( mpOutliner )->GetIgnoreCurrentPageChangesLevel()==0 && !mbFirstPaint)
+ {
+ // if we found a paragraph, select its text at the outliner view
+ Paragraph* pPara = GetParagraphForPage( mpOutliner, pActual );
+ if( pPara )
+ mpOutlinerView[0]->Select( pPara, sal_True, sal_False );
+ }
+}
+
+/*************************************************************************
+|*
+|* StyleSheet aus der Selektion besorgen
+|*
+\************************************************************************/
+
+SfxStyleSheet* OutlineView::GetStyleSheet() const
+{
+ ::sd::Window* pActWin = mpOutlineViewShell->GetActiveWindow();
+ OutlinerView* pOlView = GetViewByWindow(pActWin);
+ SfxStyleSheet* pResult = pOlView->GetStyleSheet();
+ return pResult;
+}
+
+
+
+/*************************************************************************
+|*
+|* Seiten als selektiert / nicht selektiert setzen
+|*
+\************************************************************************/
+
+void OutlineView::SetSelectedPages()
+{
+ // Liste der selektierten Titelabsaetze
+ List* pSelParas = mpOutlinerView[0]->CreateSelectionList();
+ Paragraph* pPara = (Paragraph*) pSelParas->First();
+
+ while(pPara)
+ {
+ if( !mpOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) )
+ {
+ pSelParas->Remove();
+ pPara = (Paragraph*) pSelParas->GetCurObject();
+ }
+ else
+ {
+ pPara = (Paragraph*) pSelParas->Next();
+ }
+ }
+
+ // Die zu den selektierten Absaetzen auf Ebene 0 gehoerenden Seiten
+ // selektieren
+ sal_uInt16 nPos = 0;
+ sal_uLong nParaPos = 0;
+ pPara = mpOutliner->GetParagraph( 0 );
+
+ while(pPara)
+ {
+ if( mpOutliner->HasParaFlag(pPara, PARAFLAG_ISPAGE) ) // eine Seite?
+ {
+ SdPage* pPage = mpDoc->GetSdPage(nPos, PK_STANDARD);
+ DBG_ASSERT(pPage!=NULL,
+ "Trying to select non-existing page OutlineView::SetSelectedPages()");
+ if (pPage != NULL)
+ {
+ pPage->SetSelected(sal_False);
+
+ if (pSelParas->Seek(pPara)) // selektiert?
+ pPage->SetSelected(sal_True);
+ }
+
+ nPos++;
+ }
+
+ pPara = mpOutliner->GetParagraph( ++nParaPos );
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Neue Links setzen
+|*
+\************************************************************************/
+
+void OutlineView::SetLinks()
+{
+ // Benachrichtigungs-Links setzen
+ mpOutliner->SetParaInsertedHdl(LINK(this, OutlineView, ParagraphInsertedHdl));
+ mpOutliner->SetParaRemovingHdl(LINK(this, OutlineView, ParagraphRemovingHdl));
+ mpOutliner->SetDepthChangedHdl(LINK(this, OutlineView, DepthChangedHdl));
+ mpOutliner->SetBeginMovingHdl(LINK(this, OutlineView, BeginMovingHdl));
+ mpOutliner->SetEndMovingHdl(LINK(this, OutlineView, EndMovingHdl));
+ mpOutliner->SetRemovingPagesHdl(LINK(this, OutlineView, RemovingPagesHdl));
+ mpOutliner->SetIndentingPagesHdl(LINK(this, OutlineView, IndentingPagesHdl));
+ mpOutliner->SetStatusEventHdl(LINK(this, OutlineView, StatusEventHdl));
+ mpOutliner->SetBeginDropHdl(LINK(this,OutlineView, BeginDropHdl));
+ mpOutliner->SetEndDropHdl(LINK(this,OutlineView, EndDropHdl));
+ mpOutliner->SetPaintFirstLineHdl(LINK(this,OutlineView,PaintingFirstLineHdl));
+ mpOutliner->SetBeginPasteOrDropHdl(LINK(this,OutlineView, BeginPasteOrDropHdl));
+ mpOutliner->SetEndPasteOrDropHdl(LINK(this,OutlineView, EndPasteOrDropHdl));
+}
+
+
+
+/*************************************************************************
+|*
+|* Alte Links restaurieren
+|*
+\************************************************************************/
+
+void OutlineView::ResetLinks() const
+{
+ // alte Links restaurieren
+ Link aEmptyLink;
+ mpOutliner->SetParaInsertedHdl(aEmptyLink);
+ mpOutliner->SetParaRemovingHdl(aEmptyLink);
+ mpOutliner->SetDepthChangedHdl(aEmptyLink);
+ mpOutliner->SetBeginMovingHdl(aEmptyLink);
+ mpOutliner->SetEndMovingHdl(aEmptyLink);
+ mpOutliner->SetStatusEventHdl(aEmptyLink);
+ mpOutliner->SetRemovingPagesHdl(aEmptyLink);
+ mpOutliner->SetIndentingPagesHdl(aEmptyLink);
+ mpOutliner->SetDrawPortionHdl(aEmptyLink);
+ mpOutliner->SetBeginPasteOrDropHdl(aEmptyLink);
+ mpOutliner->SetEndPasteOrDropHdl(aEmptyLink);
+}
+
+/*************************************************************************
+|*
+|* AcceptDrop
+|*
+\************************************************************************/
+
+sal_Int8 OutlineView::AcceptDrop( const AcceptDropEvent&, DropTargetHelper&, ::sd::Window*, sal_uInt16, sal_uInt16)
+{
+ return DND_ACTION_NONE;
+}
+
+/*************************************************************************
+|*
+|* ExecuteDrop
+|*
+\************************************************************************/
+
+sal_Int8 OutlineView::ExecuteDrop( const ExecuteDropEvent&, DropTargetHelper&, ::sd::Window*, sal_uInt16, sal_uInt16)
+{
+ return DND_ACTION_NONE;
+}
+
+// #97766# Re-implement GetScriptType for this view to get correct results
+sal_uInt16 OutlineView::GetScriptType() const
+{
+ sal_uInt16 nScriptType = ::sd::View::GetScriptType();
+
+ if(mpOutliner)
+ {
+ OutlinerParaObject* pTempOPObj = mpOutliner->CreateParaObject();
+
+ if(pTempOPObj)
+ {
+ nScriptType = pTempOPObj->GetTextObject().GetScriptType();
+ delete pTempOPObj;
+ }
+ }
+
+ return nScriptType;
+}
+
+void OutlineView::onUpdateStyleSettings( bool bForceUpdate /* = false */ )
+{
+ const bool bHighContrastMode = Application::GetSettings().GetStyleSettings().GetHighContrastMode() != 0;
+ if( bForceUpdate || (mbHighContrastMode != bHighContrastMode) )
+ {
+ if( mpOutliner )
+ {
+ mpOutliner->ForceAutoColor( bHighContrastMode );
+ }
+ mbHighContrastMode = bHighContrastMode;
+
+ }
+
+ svtools::ColorConfig aColorConfig;
+ const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
+ if( bForceUpdate || (maDocColor != aDocColor) )
+ {
+ sal_uInt16 nView;
+ for( nView = 0; nView < MAX_OUTLINERVIEWS; nView++ )
+ {
+ if (mpOutlinerView[nView] != NULL)
+ {
+ mpOutlinerView[nView]->SetBackgroundColor( aDocColor );
+
+ ::Window* pWindow = mpOutlinerView[nView]->GetWindow();
+
+ if( pWindow )
+ pWindow->SetBackground( Wallpaper( aDocColor ) );
+
+ }
+ }
+
+ if( mpOutliner )
+ mpOutliner->SetBackgroundColor( aDocColor );
+
+ maDocColor = aDocColor;
+ }
+}
+
+IMPL_LINK( OutlineView, AppEventListenerHdl, void *, EMPTYARG )
+{
+ onUpdateStyleSettings();
+ return 0;
+}
+
+
+
+
+IMPL_LINK(OutlineView, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent)
+{
+ if (pEvent != NULL)
+ {
+ switch (pEvent->meEventId)
+ {
+ case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
+ SetActualPage(mpOutlineViewShell->GetActualPage());
+ InvalidateSlideNumberArea();
+ break;
+
+ case tools::EventMultiplexerEvent::EID_PAGE_ORDER:
+ if (mpOutliner != NULL && mpDoc!=NULL && mpOutliner != NULL && dynamic_cast<Outliner*> ( mpOutliner )->GetIgnoreCurrentPageChangesLevel()==0)
+ {
+ if (((mpDoc->GetPageCount()-1)%2) == 0)
+ {
+ mpOutliner->Clear();
+ FillOutliner();
+ ::sd::Window* pWindow = mpOutlineViewShell->GetActiveWindow();
+ if (pWindow != NULL)
+ pWindow->Invalidate();
+ }
+ }
+ break;
+ }
+ }
+ return 0;
+}
+
+void OutlineView::IgnoreCurrentPageChanges (bool bIgnoreChanges)
+{
+ if ( mpOutliner )
+ {
+ if (bIgnoreChanges)
+ dynamic_cast<Outliner*> ( mpOutliner )->IncreIgnoreCurrentPageChangesLevel();
+ else
+ dynamic_cast<Outliner*> ( mpOutliner )->DecreIgnoreCurrentPageChangesLevel();
+ }
+}
+
+/** call this method before you do anything that can modify the outliner
+ and or the drawing document model. It will create needed undo actions */
+void OutlineView::BeginModelChange()
+{
+ const String aEmpty;
+ mpOutliner->GetUndoManager().EnterListAction(aEmpty,aEmpty);
+ const String aUndoStr(SdResId(STR_UNDO_CHANGE_TITLE_AND_LAYOUT));
+ BegUndo(aUndoStr);
+}
+
+/** call this method after BeginModelChange(), when all possible model
+ changes are done. */
+void OutlineView::EndModelChange()
+{
+ UpdateDocument();
+
+ ::svl::IUndoManager* pDocUndoMgr = mpDocSh->GetUndoManager();
+
+ bool bHasUndoActions = pDocUndoMgr->GetUndoActionCount() != 0;
+
+ EndUndo();
+
+ DBG_ASSERT( bHasUndoActions == (mpOutliner->GetUndoManager().GetUndoActionCount() != 0), "sd::OutlineView::EndModelChange(), undo actions not in sync!" );
+
+ if( bHasUndoActions )
+ {
+ SfxLinkUndoAction* pLink = new SfxLinkUndoAction(pDocUndoMgr);
+ mpOutliner->GetUndoManager().AddUndoAction(pLink);
+ }
+
+ mpOutliner->GetUndoManager().LeaveListAction();
+
+ if( bHasUndoActions && mpOutliner->GetEditEngine().HasTriedMergeOnLastAddUndo() )
+ TryToMergeUndoActions();
+
+ mpOutlineViewShell->Invalidate( SID_UNDO );
+ mpOutlineViewShell->Invalidate( SID_REDO );
+}
+
+/** updates all changes in the outliner model to the draw model */
+void OutlineView::UpdateDocument()
+{
+ const sal_uInt32 nPageCount = mpDoc->GetSdPageCount(PK_STANDARD);
+ Paragraph* pPara = mpOutliner->GetParagraph( 0 );
+ sal_uInt32 nPage;
+ for (nPage = 0; nPage < nPageCount; nPage++)
+ {
+ SdPage* pPage = mpDoc->GetSdPage( (sal_uInt16)nPage, PK_STANDARD);
+ mpDoc->SetSelected(pPage, sal_False);
+
+ mpOutlineViewShell->UpdateTitleObject( pPage, pPara );
+ mpOutlineViewShell->UpdateOutlineObject( pPage, pPara );
+
+ if( pPara )
+ pPara = GetNextTitle(pPara);
+ }
+
+ DBG_ASSERT( pPara == 0, "sd::OutlineView::UpdateDocument(), slides are out of sync, creating missing ones" );
+ while( pPara )
+ {
+ SdPage* pPage = InsertSlideForParagraph( pPara );
+ mpDoc->SetSelected(pPage, sal_False);
+
+ mpOutlineViewShell->UpdateTitleObject( pPage, pPara );
+ mpOutlineViewShell->UpdateOutlineObject( pPage, pPara );
+
+ if( pPara )
+ pPara = GetNextTitle(pPara);
+ }
+}
+
+/** merge edit engine undo actions if possible */
+void OutlineView::TryToMergeUndoActions()
+{
+ ::svl::IUndoManager& rOutlineUndo = mpOutliner->GetUndoManager();
+ if( rOutlineUndo.GetUndoActionCount() > 1 )
+ {
+ SfxListUndoAction* pListAction = dynamic_cast< SfxListUndoAction* >( rOutlineUndo.GetUndoAction(0) );
+ SfxListUndoAction* pPrevListAction = dynamic_cast< SfxListUndoAction* >( rOutlineUndo.GetUndoAction(1) );
+ if( pListAction && pPrevListAction )
+ {
+ // find the top EditUndo action in the top undo action list
+ size_t nAction = pListAction->aUndoActions.size();
+ EditUndo* pEditUndo = 0;
+ while( !pEditUndo && nAction )
+ {
+ pEditUndo = dynamic_cast< EditUndo* >(pListAction->aUndoActions[--nAction].pAction);
+ }
+
+ sal_uInt16 nEditPos = nAction; // we need this later to remove the merged undo actions
+
+ // make sure it is the only EditUndo action in the top undo list
+ while( pEditUndo && nAction )
+ {
+ if( dynamic_cast< EditUndo* >(pListAction->aUndoActions[--nAction].pAction) )
+ pEditUndo = 0;
+ }
+
+ // do we have one and only one EditUndo action in the top undo list?
+ if( pEditUndo )
+ {
+ // yes, see if we can merge it with the prev undo list
+
+ nAction = pPrevListAction->aUndoActions.size();
+ EditUndo* pPrevEditUndo = 0;
+ while( !pPrevEditUndo && nAction )
+ pPrevEditUndo = dynamic_cast< EditUndo* >(pPrevListAction->aUndoActions[--nAction].pAction);
+
+ if( pPrevEditUndo && pPrevEditUndo->Merge( pEditUndo ) )
+ {
+ // ok we merged the only EditUndo of the top undo list with
+ // the top EditUndo of the previous undo list
+
+ // first remove the merged undo action
+ DBG_ASSERT( pListAction->aUndoActions[nEditPos].pAction == pEditUndo,
+ "sd::OutlineView::TryToMergeUndoActions(), wrong edit pos!" );
+ pListAction->aUndoActions.Remove(nEditPos);
+ delete pEditUndo;
+
+ // now check if we also can merge the draw undo actions
+ ::svl::IUndoManager* pDocUndoManager = mpDocSh->GetUndoManager();
+ if( pDocUndoManager && ( pListAction->aUndoActions.size() == 1 ))
+ {
+ SfxLinkUndoAction* pLinkAction = dynamic_cast< SfxLinkUndoAction* >( pListAction->aUndoActions[0].pAction );
+ SfxLinkUndoAction* pPrevLinkAction = 0;
+
+ if( pLinkAction )
+ {
+ nAction = pPrevListAction->aUndoActions.size();
+ while( !pPrevLinkAction && nAction )
+ pPrevLinkAction = dynamic_cast< SfxLinkUndoAction* >(pPrevListAction->aUndoActions[--nAction].pAction);
+ }
+
+ if( pLinkAction && pPrevLinkAction &&
+ ( pLinkAction->GetAction() == pDocUndoManager->GetUndoAction(0) ) &&
+ ( pPrevLinkAction->GetAction() == pDocUndoManager->GetUndoAction(1) ) )
+ {
+ SfxListUndoAction* pSourceList = dynamic_cast< SfxListUndoAction* >(pLinkAction->GetAction());
+ SfxListUndoAction* pDestinationList = dynamic_cast< SfxListUndoAction* >(pPrevLinkAction->GetAction());
+
+ if( pSourceList && pDestinationList )
+ {
+ sal_uInt16 nCount = pSourceList->aUndoActions.size();
+ sal_uInt16 nDestAction = pDestinationList->aUndoActions.size();
+ while( nCount-- )
+ {
+ SfxUndoAction* pTemp = pSourceList->aUndoActions[0].pAction;
+ pSourceList->aUndoActions.Remove(0);
+ pDestinationList->aUndoActions.Insert( pTemp, nDestAction++ );
+ }
+ pDestinationList->nCurUndoAction = pDestinationList->aUndoActions.size();
+
+ pListAction->aUndoActions.Remove(0);
+ delete pLinkAction;
+
+ pDocUndoManager->RemoveLastUndoAction();
+ }
+ }
+ }
+
+ if ( !pListAction->aUndoActions.empty() )
+ {
+ // now we have to move all remaining doc undo actions from the top undo
+ // list to the previous undo list and remove the top undo list
+
+ size_t nCount = pListAction->aUndoActions.size();
+ size_t nDestAction = pPrevListAction->aUndoActions.size();
+ while( nCount-- )
+ {
+ SfxUndoAction* pTemp = pListAction->aUndoActions[0].pAction;
+ pListAction->aUndoActions.Remove(0);
+ if( pTemp )
+ pPrevListAction->aUndoActions.Insert( pTemp, nDestAction++ );
+ }
+ pPrevListAction->nCurUndoAction = pPrevListAction->aUndoActions.size();
+ }
+
+ rOutlineUndo.RemoveLastUndoAction();
+ }
+ }
+ }
+ }
+}
+
+IMPL_LINK(OutlineView, PaintingFirstLineHdl, PaintFirstLineInfo*, pInfo)
+{
+ if( pInfo && mpOutliner )
+ {
+ Paragraph* pPara = mpOutliner->GetParagraph( pInfo->mnPara );
+ EditEngine& rEditEngine = const_cast< EditEngine& >( mpOutliner->GetEditEngine() );
+
+ Size aImageSize( pInfo->mpOutDev->PixelToLogic( maSlideImage.GetSizePixel() ) );
+ Size aOffset( 100, 100 );
+
+ // paint slide number
+ if( pPara && mpOutliner->HasParaFlag(pPara,PARAFLAG_ISPAGE) )
+ {
+ long nPage = 0; // todo, printing??
+ for ( sal_uInt16 n = 0; n <= pInfo->mnPara; n++ )
+ {
+ Paragraph* p = mpOutliner->GetParagraph( n );
+ if ( mpOutliner->HasParaFlag(p,PARAFLAG_ISPAGE) )
+ nPage++;
+ }
+
+ long nBulletHeight = (long)mpOutliner->GetLineHeight( pInfo->mnPara );
+ long nFontHeight = 0;
+ if ( !rEditEngine.IsFlatMode() )
+ {
+// const SvxFontHeightItem& rFH = (const SvxFontHeightItem&)rEditEngine.GetParaAttrib( pInfo->mnPara, EE_CHAR_FONTHEIGHT );
+// nBulletHeight = rFH.GetHeight();
+ nFontHeight = nBulletHeight / 5;
+ }
+ else
+ {
+// const SvxFontHeightItem& rFH = (const SvxFontHeightItem&)rEditEngine.GetEmptyItemSet().Get( EE_CHAR_FONTHEIGHT );
+ // nBulletHeight = rFH.GetHeight();
+ nFontHeight = (nBulletHeight * 10) / 25;
+ }
+
+ Size aFontSz( 0, nFontHeight );
+
+ Size aOutSize( 2000, nBulletHeight );
+
+ const float fImageHeight = ((float)aOutSize.Height() * (float)4) / (float)7;
+ const float fImageRatio = (float)aImageSize.Height() / (float)aImageSize.Width();
+ aImageSize.Width() = (long)( fImageRatio * fImageHeight );
+ aImageSize.Height() = (long)( fImageHeight );
+
+ Point aImagePos( pInfo->mrStartPos );
+ aImagePos.X() += aOutSize.Width() - aImageSize.Width() - aOffset.Width() ;
+ aImagePos.Y() += (aOutSize.Height() - aImageSize.Height()) / 2;
+
+ pInfo->mpOutDev->DrawImage( aImagePos, aImageSize, maSlideImage );
+
+ const bool bVertical = mpOutliner->IsVertical();
+ const bool bRightToLeftPara = rEditEngine.IsRightToLeft( pInfo->mnPara );
+
+ LanguageType eLang = rEditEngine.GetDefaultLanguage();
+
+ Point aTextPos( aImagePos.X() - aOffset.Width(), pInfo->mrStartPos.Y() );
+ Font aNewFont( OutputDevice::GetDefaultFont( DEFAULTFONT_SANS_UNICODE, eLang, 0 ) );
+ aNewFont.SetSize( aFontSz );
+// aNewFont.SetAlign( aBulletFont.GetAlign() );
+ aNewFont.SetVertical( bVertical );
+ aNewFont.SetOrientation( bVertical ? 2700 : 0 );
+ aNewFont.SetColor( COL_AUTO );
+ pInfo->mpOutDev->SetFont( aNewFont );
+ String aPageText = String::CreateFromInt32( nPage );
+ Size aTextSz;
+ aTextSz.Width() = pInfo->mpOutDev->GetTextWidth( aPageText );
+ aTextSz.Height() = pInfo->mpOutDev->GetTextHeight();
+// long nBulletHeight = !bVertical ? aBulletArea.GetHeight() : aBulletArea.GetWidth();
+ if ( !bVertical )
+ {
+ aTextPos.Y() += (aOutSize.Height() - aTextSz.Height()) / 2;
+ if ( !bRightToLeftPara )
+ {
+ aTextPos.X() -= aTextSz.Width();
+ }
+ else
+ {
+ aTextPos.X() += aTextSz.Width();
+ }
+ }
+ else
+ {
+ aTextPos.Y() -= aTextSz.Width();
+ aTextPos.X() += nBulletHeight / 2;
+ }
+ pInfo->mpOutDev->DrawText( aTextPos, aPageText );
+ }
+ }
+
+ return 0;
+}
+
+#if 0
+sal_Int32 OutlineView::GetPageNumberWidthPixel()
+{
+ Window* pActWin = mpOutlineViewShell->GetActiveWindow();
+ if( pActWin )
+ {
+ Font aOldFont( pActWin->GetFont() );
+ pActWin->SetFont( maPageNumberFont );
+ Size aSize( pActWin->GetTextWidth( String( RTL_CONSTASCII_USTRINGPARAM("X" ) ) ), 0 );
+ sal_Int32 nWidth = pActWin->LogicToPixel( aSize ).Width() * 5;
+
+ const String aBulletStr( sal_Unicode( 0xE011 ) );
+ pActWin->SetFont( maBulletFont);
+
+ aSize.Width() = pActWin->GetTextWidth(aBulletStr);
+ nWidth += pActWin->LogicToPixel( aSize ).Width();
+
+ pActWin->SetFont( aOldFont );
+
+ mnPageNumberWidthPixel = nWidth;
+ }
+ return mnPageNumberWidthPixel;
+}
+#endif
+
+// --------------------------------------------------------------------
+
+void OutlineView::UpdateParagraph( sal_uInt16 nPara )
+{
+ if( mpOutliner )
+ {
+ SfxItemSet aNewAttrs2( mpOutliner->GetParaAttribs( nPara ) );
+ aNewAttrs2.Put( maLRSpaceItem );
+ mpOutliner->SetParaAttribs( nPara, aNewAttrs2 );
+ }
+}
+
+// --------------------------------------------------------------------
+
+void OutlineView::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
+{
+}
+
+/** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
+ get the correct style sheet and new slides are inserted. */
+void OutlineView::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
+{
+ SdPage* pPage = 0;
+ SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
+
+ for( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
+ {
+ Paragraph* pPara = mpOutliner->GetParagraph( nPara );
+
+ bool bPage = mpOutliner->HasParaFlag( pPara, PARAFLAG_ISPAGE );
+
+ if( !bPage )
+ {
+ SdStyleSheet* pStyleSheet = dynamic_cast< SdStyleSheet* >( mpOutliner->GetStyleSheet( nPara ) );
+ if( pStyleSheet )
+ {
+ const OUString aName( pStyleSheet->GetApiName() );
+ if( aName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("title" ) ) )
+ bPage = true;
+ }
+ }
+
+ if( !pPara )
+ continue; // fatality!?
+
+ if( bPage && (nPara != pInfos->nStartPara) )
+ {
+ // insert new slide for this paragraph
+ pPage = InsertSlideForParagraph( pPara );
+ }
+ else
+ {
+ // newly inserted non page paragraphs get the outline style
+ if( !pPage )
+ pPage = GetPageForParagraph( pPara );
+
+ if( pPage )
+ {
+ SfxStyleSheet* pStyle = pPage->GetStyleSheetForPresObj( bPage ? PRESOBJ_TITLE : PRESOBJ_OUTLINE );
+
+ if( !bPage )
+ {
+ const sal_Int16 nDepth = mpOutliner->GetDepth( nPara );
+ if( nDepth > 0 )
+ {
+ String aStyleSheetName( pStyle->GetName() );
+ aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
+ aStyleSheetName += String::CreateFromInt32( nDepth );
+ pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyle->GetFamily() ) );
+ DBG_ASSERT( pStyle, "sd::OutlineView::OnEndPasteOrDrop(), Style not found!" );
+ }
+ }
+
+ mpOutliner->SetStyleSheet( nPara, pStyle );
+ }
+
+ UpdateParagraph( nPara );
+ }
+ }
+}
+
+// ====================================================================
+
+
+OutlineViewModelChangeGuard::OutlineViewModelChangeGuard( OutlineView& rView )
+: mrView( rView )
+{
+ mrView.BeginModelChange();
+}
+
+OutlineViewModelChangeGuard::~OutlineViewModelChangeGuard()
+{
+ mrView.EndModelChange();
+}
+
+OutlineViewPageChangesGuard::OutlineViewPageChangesGuard( OutlineView* pView )
+: mpView( pView )
+{
+ if( mpView )
+ mpView->IgnoreCurrentPageChanges( true );
+}
+
+OutlineViewPageChangesGuard::~OutlineViewPageChangesGuard()
+{
+ if( mpView )
+ mpView->IgnoreCurrentPageChanges( false );
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/presvish.cxx b/sd/source/ui/view/presvish.cxx
new file mode 100755
index 000000000000..d3c952a294a8
--- /dev/null
+++ b/sd/source/ui/view/presvish.cxx
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * 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 <com/sun/star/presentation/XSlideShowController.hpp>
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <comphelper/processfactory.hxx>
+
+#include "PresentationViewShell.hxx"
+#include "optsitem.hxx"
+#include "sddll.hxx"
+#include <sfx2/request.hxx>
+#ifndef _SFX_DISPATCH_HXX
+#include <sfx2/dispatch.hxx>
+#endif
+
+#include <sfx2/objface.hxx>
+
+#include <svx/svxids.hrc>
+#ifndef SD_FRAME_VIEW
+#include "FrameView.hxx"
+#endif
+#include "sdresid.hxx"
+#include "DrawDocShell.hxx"
+#include "slideshow.hxx"
+#include "sdattr.hxx"
+#include "sdpage.hxx"
+#include "drawdoc.hxx"
+#include "drawview.hxx"
+#include "app.hrc"
+#include "strings.hrc"
+#include "glob.hrc"
+#include "ViewShellBase.hxx"
+#include "FactoryIds.hxx"
+
+// #110496#
+#include "slideshow.hxx"
+#include "fupoor.hxx"
+#include "Window.hxx"
+
+#define PresentationViewShell
+using namespace sd;
+#include "sdslots.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::presentation;
+
+namespace sd {
+
+// -------------------
+// - PresentationViewShell -
+// -------------------
+
+SFX_IMPL_INTERFACE( PresentationViewShell, DrawViewShell, SdResId( STR_PRESVIEWSHELL ) )
+{
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_TOOLS | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_FULLSCREEN | SFX_VISIBILITY_SERVER,
+ SdResId(RID_DRAW_TOOLBOX));
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER | SFX_VISIBILITY_READONLYDOC,
+ SdResId(RID_DRAW_VIEWER_TOOLBOX) );
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OPTIONS | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_SERVER,
+ SdResId(RID_DRAW_OPTIONS_TOOLBOX));
+ SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_COMMONTASK | SFX_VISIBILITY_STANDARD |
+ SFX_VISIBILITY_SERVER,
+ SdResId(RID_DRAW_COMMONTASK_TOOLBOX));
+}
+
+
+TYPEINIT1( PresentationViewShell, DrawViewShell );
+
+PresentationViewShell::PresentationViewShell( SfxViewFrame* pFrame, ViewShellBase& rViewShellBase, ::Window* pParentWindow, FrameView* pFrameView)
+: DrawViewShell( pFrame, rViewShellBase, pParentWindow, PK_STANDARD, pFrameView)
+{
+ if( GetDocSh() && GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ maOldVisArea = GetDocSh()->GetVisArea( ASPECT_CONTENT );
+ meShellType = ST_PRESENTATION;
+}
+
+PresentationViewShell::~PresentationViewShell (void)
+{
+ if( GetDocSh() && GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED && !maOldVisArea.IsEmpty() )
+ GetDocSh()->SetVisArea( maOldVisArea );
+}
+
+void PresentationViewShell::FinishInitialization( FrameView* pFrameView )
+{
+ DrawViewShell::Init(true);
+
+ // Use the frame view that comes form the view shell that initiated our
+ // creation.
+ if (pFrameView != NULL)
+ {
+ GetFrameView()->Disconnect();
+ SetFrameView (pFrameView);
+ pFrameView->Connect();
+ }
+ SetRuler(false);
+// SwitchPage (nPageNumber);
+ WriteFrameViewData();
+
+ GetActiveWindow()->GrabFocus();
+}
+
+
+SvxRuler* PresentationViewShell::CreateHRuler(::sd::Window*, sal_Bool)
+{
+ return NULL;
+}
+
+SvxRuler* PresentationViewShell::CreateVRuler(::sd::Window*)
+{
+ return NULL;
+}
+
+
+void PresentationViewShell::Activate( sal_Bool bIsMDIActivate )
+{
+ DrawViewShell::Activate( bIsMDIActivate );
+
+ if( bIsMDIActivate )
+ {
+ //HMH::sd::View* pView = GetView();
+ SfxBoolItem aItem( SID_NAVIGATOR_INIT, sal_True );
+
+ GetViewFrame()->GetDispatcher()->Execute( SID_NAVIGATOR_INIT, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, &aItem, 0L );
+
+ rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if( xSlideShow.is() )
+ xSlideShow->activate(GetViewShellBase());
+
+ if( HasCurrentFunction() )
+ GetCurrentFunction()->Activate();
+ }
+
+ if( bIsMDIActivate )
+ ReadFrameViewData( mpFrameView );
+ GetDocSh()->Connect( this );
+}
+
+void PresentationViewShell::Paint( const Rectangle& rRect, ::sd::Window* )
+{
+ rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if( xSlideShow.is() )
+ xSlideShow->paint(rRect);
+}
+
+void PresentationViewShell::Resize (void)
+{
+ ViewShell::Resize(); // do not call DrawViewShell here!
+
+ rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if( xSlideshow.is() )
+ xSlideshow->resize(maViewSize);
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/sdruler.cxx b/sd/source/ui/view/sdruler.cxx
new file mode 100755
index 000000000000..2964f5e79219
--- /dev/null
+++ b/sd/source/ui/view/sdruler.cxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * 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 "Ruler.hxx"
+#include <svl/ptitem.hxx>
+#include <svx/ruler.hxx>
+#ifndef _SVXIDS_HXX //autogen
+#include <svx/svxids.hrc>
+#endif
+#include <sfx2/ctrlitem.hxx>
+#include <sfx2/bindings.hxx>
+
+
+#include "View.hxx"
+#include "DrawViewShell.hxx"
+#include "Window.hxx"
+
+#include "helpids.h"
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Controller-Item fuer Ruler
+|*
+\************************************************************************/
+
+class RulerCtrlItem : public SfxControllerItem
+{
+ Ruler &rRuler;
+
+ protected:
+ virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
+ const SfxPoolItem* pItem );
+
+ public:
+ RulerCtrlItem(sal_uInt16 nId, Ruler& rRlr, SfxBindings& rBind);
+};
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+RulerCtrlItem::RulerCtrlItem(sal_uInt16 _nId, Ruler& rRlr, SfxBindings& rBind)
+: SfxControllerItem(_nId, rBind)
+, rRuler(rRlr)
+{
+}
+
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void RulerCtrlItem::StateChanged( sal_uInt16 nSId, SfxItemState, const SfxPoolItem* pState )
+{
+ switch( nSId )
+ {
+ case SID_RULER_NULL_OFFSET:
+ {
+ const SfxPointItem* pItem = dynamic_cast< const SfxPointItem* >(pState);
+ DBG_ASSERT(pState ? pItem != NULL : sal_True, "SfxPointItem erwartet");
+ if ( pItem )
+ rRuler.SetNullOffset(pItem->GetValue());
+ }
+ break;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+Ruler::Ruler( DrawViewShell& rViewSh, ::Window* pParent, ::sd::Window* pWin, sal_uInt16 nRulerFlags, SfxBindings& rBindings, WinBits nWinStyle)
+: SvxRuler(pParent, pWin, nRulerFlags, rBindings, nWinStyle)
+, pSdWin(pWin)
+, pDrViewShell(&rViewSh)
+{
+ rBindings.EnterRegistrations();
+ pCtrlItem = new RulerCtrlItem(SID_RULER_NULL_OFFSET, *this, rBindings);
+ rBindings.LeaveRegistrations();
+
+ if ( nWinStyle & WB_HSCROLL )
+ {
+ bHorz = sal_True;
+ SetHelpId( HID_SD_RULER_HORIZONTAL );
+ }
+ else
+ {
+ bHorz = sal_False;
+ SetHelpId( HID_SD_RULER_VERTICAL );
+ }
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+Ruler::~Ruler()
+{
+ SfxBindings& rBindings = pCtrlItem->GetBindings();
+ rBindings.EnterRegistrations();
+ delete pCtrlItem;
+ rBindings.LeaveRegistrations();
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown-Handler
+|*
+\************************************************************************/
+
+void Ruler::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ Point aMPos = rMEvt.GetPosPixel();
+ RulerType eType = GetType(aMPos);
+
+ if ( !pDrViewShell->GetView()->IsTextEdit() &&
+ rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
+ (eType == RULER_TYPE_DONTKNOW || eType == RULER_TYPE_OUTSIDE) )
+ {
+ pDrViewShell->StartRulerDrag(*this, rMEvt);
+ }
+ else
+ SvxRuler::MouseButtonDown(rMEvt);
+}
+
+/*************************************************************************
+|*
+|* MouseMove-Handler
+|*
+\************************************************************************/
+
+void Ruler::MouseMove(const MouseEvent& rMEvt)
+{
+ SvxRuler::MouseMove(rMEvt);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp-Handler
+|*
+\************************************************************************/
+
+void Ruler::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ SvxRuler::MouseButtonUp(rMEvt);
+}
+
+/*************************************************************************
+|*
+|* NullOffset setzen
+|*
+\************************************************************************/
+
+void Ruler::SetNullOffset(const Point& rOffset)
+{
+ long nOffset;
+
+ if ( bHorz ) nOffset = rOffset.X();
+ else nOffset = rOffset.Y();
+
+ SetNullOffsetLogic(nOffset);
+}
+
+/*************************************************************************
+|*
+|* Command event
+|*
+\************************************************************************/
+
+void Ruler::Command(const CommandEvent& rCEvt)
+{
+ if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU &&
+ !pDrViewShell->GetView()->IsTextEdit() )
+ {
+ SvxRuler::Command( rCEvt );
+ }
+}
+
+/*************************************************************************
+|*
+|* ExtraDown
+|*
+\************************************************************************/
+
+void Ruler::ExtraDown()
+{
+ if( !pDrViewShell->GetView()->IsTextEdit() )
+ SvxRuler::ExtraDown();
+}
+
+} // end of namespace sd
+
diff --git a/sd/source/ui/view/sdview.cxx b/sd/source/ui/view/sdview.cxx
new file mode 100755
index 000000000000..23d57c26ad33
--- /dev/null
+++ b/sd/source/ui/view/sdview.cxx
@@ -0,0 +1,1316 @@
+/*************************************************************************
+ *
+ * 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 <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/linguistic2/XSpellChecker1.hpp>
+
+#include "View.hxx"
+#include <editeng/unolingu.hxx>
+#include <sfx2/request.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/fmview.hxx>
+#include <editeng/outliner.hxx>
+#ifndef _SVX_SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <svx/svdograf.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdundo.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#include <svx/svdpagv.hxx>
+#include <sfx2/docfile.hxx>
+#include <svx/svdoutl.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+
+#include <svx/svdetc.hxx>
+#include <editeng/editstat.hxx>
+
+#include <svx/dialogs.hrc>
+#include <sfx2/viewfrm.hxx>
+#include <svx/svdopage.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <svx/xlndsit.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlnclit.hxx>
+#include <vcl/virdev.hxx>
+
+#include "app.hrc"
+#include "strings.hrc"
+#include "Window.hxx"
+#include "Client.hxx"
+#include "drawdoc.hxx"
+#include "DrawDocShell.hxx"
+#include "app.hxx"
+#include "sdpage.hxx"
+#include "glob.hrc"
+#include "sdresid.hxx"
+#include "DrawViewShell.hxx"
+#include "futext.hxx"
+#include "fuinsfil.hxx"
+#include "slideshow.hxx"
+#include "stlpool.hxx"
+#include "FrameView.hxx"
+#include "ViewClipboard.hxx"
+#include "undo/undomanager.hxx"
+#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/sdr/contact/viewcontact.hxx>
+#include <svx/sdr/contact/displayinfo.hxx>
+#include "EventMultiplexer.hxx"
+#include "ViewShellBase.hxx"
+#include "ViewShellManager.hxx"
+
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/color/bcolor.hxx>
+#include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <drawinglayer/primitive2d/textlayoutdevice.hxx>
+#include <drawinglayer/primitive2d/groupprimitive2d.hxx>
+#include <svx/sdr/contact/objectcontact.hxx>
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <drawinglayer/primitive2d/textprimitive2d.hxx>
+#include <svx/unoapi.hxx>
+#include <basegfx/matrix/b2dhommatrixtools.hxx>
+
+#include <numeric>
+
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+namespace sd {
+
+#ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
+#define SO2_DECL_SVINPLACEOBJECT_DEFINED
+SO2_DECL_REF(SvInPlaceObject)
+#endif
+
+TYPEINIT1(View, FmFormView);
+
+/*************************************************************************
+|*
+|* Ctor
+|*
+\************************************************************************/
+
+View::View(SdDrawDocument* pDrawDoc, OutputDevice* pOutDev,
+ ViewShell* pViewShell)
+ : FmFormView(pDrawDoc, pOutDev),
+ mpDoc(pDrawDoc),
+ mpDocSh( pDrawDoc->GetDocSh() ),
+ mpViewSh(pViewShell),
+ mpDragSrcMarkList(NULL),
+ mpDropMarkerObj(NULL),
+ mpDropMarker(NULL),
+ mnDragSrcPgNum(SDRPAGE_NOTFOUND),
+ mnAction(DND_ACTION_NONE),
+ mnLockRedrawSmph(0),
+ mpLockedRedraws(NULL),
+ mbIsDropAllowed(sal_True),
+ maSmartTags(*this),
+ mpClipboard (new ViewClipboard (*this))
+{
+ // #i73602# Use default from the configuration
+ SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_DrawImpress());
+
+ // #i74769#, #i75172# Use default from the configuration
+ SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_DrawImpress());
+
+ EnableExtendedKeyInputDispatcher(sal_False);
+ EnableExtendedMouseEventDispatcher(sal_False);
+ EnableExtendedCommandEventDispatcher(sal_False);
+
+ SetUseIncompatiblePathCreateInterface(sal_False);
+ SetMarkHdlWhenTextEdit(sal_True);
+ EnableTextEditOnObjectsWithoutTextIfTextTool(sal_True);
+
+ SetMinMoveDistancePixel(2);
+ SetHitTolerancePixel(2);
+ SetMeasureLayer(String(SdResId(STR_LAYER_MEASURELINES)));
+
+ // Timer fuer verzoegertes Drop (muss fuer MAC sein)
+ maDropErrorTimer.SetTimeoutHdl( LINK(this, View, DropErrorHdl) );
+ maDropErrorTimer.SetTimeout(50);
+ maDropInsertFileTimer.SetTimeoutHdl( LINK(this, View, DropInsertFileHdl) );
+ maDropInsertFileTimer.SetTimeout(50);
+}
+
+void View::ImplClearDrawDropMarker()
+{
+ if(mpDropMarker)
+ {
+ delete mpDropMarker;
+ mpDropMarker = 0L;
+ }
+}
+
+/*************************************************************************
+|*
+|* Dtor
+|*
+\************************************************************************/
+
+View::~View()
+{
+ maSmartTags.Dispose();
+
+ // release content of selection clipboard, if we own the content
+ UpdateSelectionClipboard( sal_True );
+
+ maDropErrorTimer.Stop();
+ maDropInsertFileTimer.Stop();
+
+ ImplClearDrawDropMarker();
+
+ while(PaintWindowCount())
+ {
+ // Alle angemeldeten OutDevs entfernen
+ DeleteWindowFromPaintView(GetFirstOutputDevice() /*GetWin(0)*/);
+ }
+
+ // gespeicherte Redraws loeschen
+ if (mpLockedRedraws)
+ {
+ SdViewRedrawRec* pRec = (SdViewRedrawRec*)mpLockedRedraws->First();
+ while (pRec)
+ {
+ delete pRec;
+ pRec = (SdViewRedrawRec*)mpLockedRedraws->Next();
+ }
+ delete mpLockedRedraws;
+ }
+}
+
+
+class ViewRedirector : public ::sdr::contact::ViewObjectContactRedirector
+{
+public:
+ ViewRedirector();
+ virtual ~ViewRedirector();
+
+ // all default implementations just call the same methods at the original. To do something
+ // different, overload the method and at least do what the method does.
+ virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
+ const sdr::contact::ViewObjectContact& rOriginal,
+ const sdr::contact::DisplayInfo& rDisplayInfo);
+};
+
+ViewRedirector::ViewRedirector()
+{
+}
+
+ViewRedirector::~ViewRedirector()
+{
+}
+
+drawinglayer::primitive2d::Primitive2DSequence ViewRedirector::createRedirectedPrimitive2DSequence(
+ const sdr::contact::ViewObjectContact& rOriginal,
+ const sdr::contact::DisplayInfo& rDisplayInfo)
+{
+ SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
+ drawinglayer::primitive2d::Primitive2DSequence xRetval;
+
+ if(pObject && pObject->GetPage())
+ {
+ const bool bDoCreateGeometry(pObject->GetPage()->checkVisibility( rOriginal, rDisplayInfo, true ));
+
+ if(!bDoCreateGeometry && !(( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE )) )
+ return xRetval;
+
+ PresObjKind eKind(PRESOBJ_NONE);
+ const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
+ const bool bIsMasterPageObject(pObject->GetPage()->IsMasterPage());
+ const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter());
+ const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
+ const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
+ const SdPage* pObjectsSdPage = dynamic_cast< SdPage* >(pObject->GetPage());
+ const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
+
+ // check if we need to draw a placeholder border. Never do it for
+ // objects inside a SdrPageObj and never when printing
+ if(!bIsInsidePageObj && !bIsPrinting)
+ {
+ bool bCreateOutline(false);
+
+ if( pObject->IsEmptyPresObj() && pObject->ISA(SdrTextObj) )
+ {
+ if( !bSubContentProcessing || !pObject->IsNotVisibleAsMaster() )
+ {
+ eKind = pObjectsSdPage ? pObjectsSdPage->GetPresObjKind(pObject) : PRESOBJ_NONE;
+ bCreateOutline = true;
+ }
+ }
+ else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_TEXT ) )
+ {
+ if( pObjectsSdPage )
+ {
+ eKind = pObjectsSdPage->GetPresObjKind(pObject);
+
+ if((eKind == PRESOBJ_FOOTER) || (eKind == PRESOBJ_HEADER) || (eKind == PRESOBJ_DATETIME) || (eKind == PRESOBJ_SLIDENUMBER) )
+ {
+ if( !bSubContentProcessing )
+ {
+ // only draw a boundary for header&footer objects on the masterpage itself
+ bCreateOutline = true;
+ }
+ }
+ }
+ }
+ else if( ( pObject->GetObjInventor() == SdrInventor ) && ( pObject->GetObjIdentifier() == OBJ_PAGE ) )
+ {
+ // only for handout page, else this frame will be created for each
+ // page preview object in SlideSorter and PagePane
+ if(pObjectsSdPage && PK_HANDOUT == pObjectsSdPage->GetPageKind())
+ {
+ bCreateOutline = true;
+ }
+ }
+
+ if(bCreateOutline)
+ {
+ // empty presentation objects get a gray frame
+ const svtools::ColorConfig aColorConfig;
+ const svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( svtools::OBJECTBOUNDARIES ) );
+
+ if( aColor.bIsVisible )
+ {
+ // get basic object transformation
+ const basegfx::BColor aRGBColor(Color(aColor.nColor).getBColor());
+ basegfx::B2DHomMatrix aObjectMatrix;
+ basegfx::B2DPolyPolygon aObjectPolyPolygon;
+ pObject->TRGetBaseGeometry(aObjectMatrix, aObjectPolyPolygon);
+
+ // create dashed border
+ {
+ // create object polygon
+ basegfx::B2DPolygon aPolygon(basegfx::tools::createUnitPolygon());
+ aPolygon.transform(aObjectMatrix);
+
+ // create line and stroke attribute
+ ::std::vector< double > aDotDashArray;
+
+ aDotDashArray.push_back(160.0);
+ aDotDashArray.push_back(80.0);
+
+ const double fFullDotDashLen(::std::accumulate(aDotDashArray.begin(), aDotDashArray.end(), 0.0));
+ const drawinglayer::attribute::LineAttribute aLine(aRGBColor);
+ const drawinglayer::attribute::StrokeAttribute aStroke(aDotDashArray, fFullDotDashLen);
+
+ // create primitive and add
+ const drawinglayer::primitive2d::Primitive2DReference xRef(new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
+ aPolygon,
+ aLine,
+ aStroke));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
+ }
+
+ // now paint the placeholder description, but only when masterpage
+ // is displayed as page directly (MasterPage view)
+ if(!bSubContentProcessing && bIsMasterPageObject)
+ {
+ String aObjectString;
+
+ switch( eKind )
+ {
+ case PRESOBJ_TITLE:
+ {
+ if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
+ {
+ static String aTitleAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_TITLE ) );
+ aObjectString = aTitleAreaStr;
+ }
+
+ break;
+ }
+ case PRESOBJ_OUTLINE:
+ {
+ static String aOutlineAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_OUTLINE ) );
+ aObjectString = aOutlineAreaStr;
+ break;
+ }
+ case PRESOBJ_FOOTER:
+ {
+ static String aFooterAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_FOOTER ) );
+ aObjectString = aFooterAreaStr;
+ break;
+ }
+ case PRESOBJ_HEADER:
+ {
+ static String aHeaderAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_HEADER ) );
+ aObjectString = aHeaderAreaStr;
+ break;
+ }
+ case PRESOBJ_DATETIME:
+ {
+ static String aDateTimeStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_DATETIME ) );
+ aObjectString = aDateTimeStr;
+ break;
+ }
+ case PRESOBJ_NOTES:
+ {
+ static String aDateTimeStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_NOTES ) );
+ aObjectString = aDateTimeStr;
+ break;
+ }
+ case PRESOBJ_SLIDENUMBER:
+ {
+ if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PK_STANDARD)
+ {
+ static String aSlideAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_SLIDE ) );
+ aObjectString = aSlideAreaStr;
+ }
+ else
+ {
+ static String aNumberAreaStr( SdResId( STR_PLACEHOLDER_DESCRIPTION_NUMBER ) );
+ aObjectString = aNumberAreaStr;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ if( aObjectString.Len() )
+ {
+ // decompose object matrix to be able to place text correctly
+ basegfx::B2DTuple aScale;
+ basegfx::B2DTuple aTranslate;
+ double fRotate, fShearX;
+ aObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
+
+ // create font
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObject );
+ const SdrTextVertAdjust eTVA(pTextObj ? pTextObj->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_CENTER);
+ Font aScaledVclFont;
+
+ // use a text size factor to get more reliable text sizes from the text layouter
+ // (and from vcl), tipp from HDU
+ static sal_uInt32 nTextSizeFactor(100);
+
+ // use a factor to get more linear text size calculations
+ aScaledVclFont.SetHeight( 500 * nTextSizeFactor );
+
+ // get basic geometry and get text size
+ drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
+ aTextLayouter.setFont(aScaledVclFont);
+ const xub_StrLen nTextLength(aObjectString.Len());
+
+ // do not forget to use the factor again to get the width for the 500
+ const double fTextWidth(aTextLayouter.getTextWidth(aObjectString, 0, nTextLength) * (1.0 / nTextSizeFactor));
+ const double fTextHeight(aTextLayouter.getTextHeight() * (1.0 / nTextSizeFactor));
+
+ // calculate text primitive position. If text is at bottom, use top for
+ // the extra text and vice versa
+ const double fHorDist(125);
+ const double fVerDist(125);
+ const double fPosX((aTranslate.getX() + aScale.getX()) - fTextWidth - fHorDist);
+ const double fPosY((SDRTEXTVERTADJUST_BOTTOM == eTVA)
+ ? aTranslate.getY() - fVerDist + fTextHeight
+ : (aTranslate.getY() + aScale.getY()) - fVerDist);
+
+ // get font attributes; use normally scaled font
+ const basegfx::BColor aFontColor(aRGBColor);
+ Font aVclFont;
+ basegfx::B2DVector aTextSizeAttribute;
+
+ aVclFont.SetHeight( 500 );
+
+ const drawinglayer::attribute::FontAttribute aFontAttribute(
+ drawinglayer::primitive2d::getFontAttributeFromVclFont(
+ aTextSizeAttribute,
+ aVclFont,
+ false,
+ false));
+
+ // fill text matrix
+ const basegfx::B2DHomMatrix aTextMatrix(basegfx::tools::createScaleShearXRotateTranslateB2DHomMatrix(
+ aTextSizeAttribute.getX(), aTextSizeAttribute.getY(),
+ fShearX,
+ fRotate,
+ fPosX, fPosY));
+
+ // create DXTextArray (can be empty one)
+ const ::std::vector< double > aDXArray;
+
+ // create locale; this may need some more information in the future
+ const ::com::sun::star::lang::Locale aLocale;
+
+ // create primitive and add
+ const drawinglayer::primitive2d::Primitive2DReference xRef(
+ new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
+ aTextMatrix,
+ aObjectString,
+ 0,
+ nTextLength,
+ aDXArray,
+ aFontAttribute,
+ aLocale,
+ aFontColor));
+ drawinglayer::primitive2d::appendPrimitive2DReferenceToPrimitive2DSequence(xRetval, xRef);
+ }
+ }
+ }
+ }
+ }
+
+ if(bDoCreateGeometry)
+ {
+ drawinglayer::primitive2d::appendPrimitive2DSequenceToPrimitive2DSequence(
+ xRetval,
+ sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
+ rOriginal,
+ rDisplayInfo));
+ }
+ }
+ else
+ {
+ // not a SdrObject visualisation (maybe e.g. page) or no page
+ xRetval = sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
+ }
+
+ return xRetval;
+}
+
+/*************************************************************************
+|*
+|* Paint-Methode: das Ereignis wird an die View weitergeleitet
+|*
+\************************************************************************/
+
+void View::CompleteRedraw(OutputDevice* pOutDev, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector /*=0L*/)
+{
+ // ausfuehren ??
+ if (mnLockRedrawSmph == 0)
+ {
+ SdrPageView* pPgView = GetSdrPageView();
+
+ if (pPgView)
+ {
+ SdPage* pPage = (SdPage*) pPgView->GetPage();
+ if( pPage )
+ {
+ SdrOutliner& rOutl=mpDoc->GetDrawOutliner(NULL);
+ bool bScreenDisplay(true);
+
+ if(bScreenDisplay && pOutDev && OUTDEV_PRINTER == pOutDev->GetOutDevType())
+ {
+ // #i75566# printing; suppress AutoColor BackgroundColor generation
+ // for visibility reasons by giving GetPageBackgroundColor()
+ // the needed hint
+ bScreenDisplay = false;
+ }
+
+ if(bScreenDisplay && pOutDev && pOutDev->GetPDFWriter())
+ {
+ // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
+ bScreenDisplay = false;
+ }
+
+ // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
+ // hint value if screen display. Only then the AutoColor mechanisms shall be applied
+ rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor(pPgView, bScreenDisplay) );
+ }
+ }
+
+ ViewRedirector aViewRedirector;
+ FmFormView::CompleteRedraw(pOutDev, rReg, pRedirector ? pRedirector : &aViewRedirector);
+ }
+ // oder speichern?
+ else
+ {
+ if (!mpLockedRedraws)
+ mpLockedRedraws = new List;
+
+ SdViewRedrawRec* pRec = new SdViewRedrawRec;
+ pRec->mpOut = pOutDev;
+ pRec->aRect = rReg.GetBoundRect();
+ mpLockedRedraws->Insert(pRec, LIST_APPEND);
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Selektion hat sich geaendert
+|*
+\************************************************************************/
+
+void View::MarkListHasChanged()
+{
+ FmFormView::MarkListHasChanged();
+
+ if( GetMarkedObjectCount() > 0 )
+ maSmartTags.deselect();
+}
+
+
+/*************************************************************************
+|*
+|* Attribute setzen
+|*
+\************************************************************************/
+
+sal_Bool View::SetAttributes(const SfxItemSet& rSet, sal_Bool bReplaceAll)
+{
+ sal_Bool bOk = FmFormView::SetAttributes(rSet, bReplaceAll);
+ return (bOk);
+}
+
+
+/*************************************************************************
+|*
+|* Attribute holen
+|*
+\************************************************************************/
+
+sal_Bool View::GetAttributes( SfxItemSet& rTargetSet, sal_Bool bOnlyHardAttr ) const
+{
+ return( FmFormView::GetAttributes( rTargetSet, bOnlyHardAttr ) );
+}
+
+
+/*************************************************************************
+|*
+|* Ist ein Praesentationsobjekt selektiert?
+|*
+\************************************************************************/
+
+sal_Bool View::IsPresObjSelected(sal_Bool bOnPage, sal_Bool bOnMasterPage, sal_Bool bCheckPresObjListOnly, sal_Bool bCheckLayoutOnly) const
+{
+ /**************************************************************************
+ * Ist ein Presentationsobjekt selektiert?
+ **************************************************************************/
+ SdrMarkList* pMarkList;
+
+ if (mnDragSrcPgNum != SDRPAGE_NOTFOUND &&
+ mnDragSrcPgNum != GetSdrPageView()->GetPage()->GetPageNum())
+ {
+ // Es laeuft gerade Drag&Drop
+ // Source- und Destination-Page unterschiedlich:
+ // es wird die gemerkte MarkList verwendet
+ pMarkList = mpDragSrcMarkList;
+ }
+ else
+ {
+ // Es wird die aktuelle MarkList verwendet
+ pMarkList = new SdrMarkList(GetMarkedObjectList());
+ }
+
+ SdrMark* pMark;
+ SdPage* pPage;
+ SdrObject* pObj;
+
+ sal_Bool bSelected = sal_False;
+ sal_Bool bMasterPage = sal_False;
+ long nMark;
+ long nMarkMax = long(pMarkList->GetMarkCount()) - 1;
+
+ for (nMark = nMarkMax; (nMark >= 0) && !bSelected; nMark--)
+ {
+ // Rueckwaerts durch die Marklist
+ pMark = pMarkList->GetMark(nMark);
+ pObj = pMark->GetMarkedSdrObj();
+
+ if ( pObj && ( bCheckPresObjListOnly || pObj->IsEmptyPresObj() || pObj->GetUserCall() ) )
+ {
+ pPage = (SdPage*) pObj->GetPage();
+ bMasterPage = pPage->IsMasterPage();
+
+ if ( (bMasterPage && bOnMasterPage) || (!bMasterPage && bOnPage) )
+ {
+ if ( pPage && pPage->IsPresObj(pObj) )
+ {
+ if( bCheckLayoutOnly )
+ {
+ PresObjKind eKind = pPage->GetPresObjKind(pObj);
+
+ if((eKind != PRESOBJ_FOOTER) && (eKind != PRESOBJ_HEADER) && (eKind != PRESOBJ_DATETIME) && (eKind != PRESOBJ_SLIDENUMBER) )
+ bSelected = sal_True;
+ }
+ else
+ {
+ bSelected = sal_True;
+ }
+ }
+ }
+ }
+ }
+
+ if (pMarkList != mpDragSrcMarkList)
+ {
+ delete pMarkList;
+ }
+
+ return (bSelected);
+}
+
+/*************************************************************************
+|*
+|* Alles selektieren
+|*
+\************************************************************************/
+
+void View::SelectAll()
+{
+ if ( IsTextEdit() )
+ {
+ OutlinerView* pOLV = GetTextEditOutlinerView();
+ const ::Outliner* pOutliner = GetTextEditOutliner();
+ pOLV->SelectRange( 0, (sal_uInt16) pOutliner->GetParagraphCount() );
+ }
+ else
+ {
+ MarkAll();
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Dokument hat sich geaendert
+|*
+\************************************************************************/
+
+void View::ModelHasChanged()
+{
+ // Erst SdrView benachrichtigen
+ FmFormView::ModelHasChanged();
+}
+
+/*************************************************************************
+|*
+|* StyleSheet setzen
+|*
+\************************************************************************/
+
+sal_Bool View::SetStyleSheet(SfxStyleSheet* pStyleSheet, sal_Bool bDontRemoveHardAttr)
+{
+ // weiter an SdrView
+ return FmFormView::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
+}
+
+
+/*************************************************************************
+|*
+|* Texteingabe beginnen
+|*
+\************************************************************************/
+
+static void SetSpellOptions( SdDrawDocument* pDoc, sal_uLong& rCntrl )
+{
+ sal_Bool bOnlineSpell = pDoc->GetOnlineSpell();
+
+ if( bOnlineSpell )
+ rCntrl |= EE_CNTRL_ONLINESPELLING;
+ else
+ rCntrl &= ~EE_CNTRL_ONLINESPELLING;
+}
+
+sal_Bool View::SdrBeginTextEdit(
+ SdrObject* pObj, SdrPageView* pPV, ::Window* pWin,
+ sal_Bool bIsNewObj,
+ SdrOutliner* pOutl, OutlinerView* pGivenOutlinerView,
+ sal_Bool bDontDeleteOutliner, sal_Bool bOnlyOneView, sal_Bool bGrabFocus )
+{
+ GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
+ sd::tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT, (void*)pObj );
+
+ if( pOutl==NULL && pObj )
+ pOutl = SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, pObj->GetModel() );
+
+ // make draw&impress specific initialisations
+ if( pOutl )
+ {
+ pOutl->SetStyleSheetPool((SfxStyleSheetPool*) mpDoc->GetStyleSheetPool());
+ pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
+ sal_uLong nCntrl = pOutl->GetControlWord();
+ nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
+ nCntrl |= EE_CNTRL_URLSFXEXECUTE;
+ nCntrl |= EE_CNTRL_MARKFIELDS;
+ nCntrl |= EE_CNTRL_AUTOCORRECT;
+
+ nCntrl &= ~EE_CNTRL_ULSPACESUMMATION;
+ if ( mpDoc->IsSummationOfParagraphs() )
+ nCntrl |= EE_CNTRL_ULSPACESUMMATION;
+
+ SetSpellOptions( mpDoc, nCntrl );
+
+ pOutl->SetControlWord(nCntrl);
+
+ Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
+ if ( xSpellChecker.is() )
+ pOutl->SetSpeller( xSpellChecker );
+
+ Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
+ if( xHyphenator.is() )
+ pOutl->SetHyphenator( xHyphenator );
+
+ pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguage() );
+ }
+
+ sal_Bool bReturn = FmFormView::SdrBeginTextEdit(
+ pObj, pPV, pWin, bIsNewObj, pOutl,
+ pGivenOutlinerView, bDontDeleteOutliner,
+ bOnlyOneView, bGrabFocus);
+
+ if (bReturn)
+ {
+ ::Outliner* pOL = GetTextEditOutliner();
+
+ if( pObj && pObj->GetPage() )
+ {
+ Color aBackground;
+ if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_TABLE )
+ {
+ aBackground = GetTextEditBackgroundColor(*this);
+ }
+ else
+ {
+ aBackground = pObj->GetPage()->GetPageBackgroundColor(pPV);
+ }
+ pOL->SetBackgroundColor( aBackground );
+ }
+
+ pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl));
+ pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl));
+ }
+
+ return(bReturn);
+}
+
+/** ends current text editing */
+SdrEndTextEditKind View::SdrEndTextEdit(sal_Bool bDontDeleteReally )
+{
+ SdrObjectWeakRef xObj( GetTextEditObject() );
+
+ sal_Bool bDefaultTextRestored = RestoreDefaultText( dynamic_cast< SdrTextObj* >( GetTextEditObject() ) );
+
+ SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
+
+ if( bDefaultTextRestored )
+ {
+ if( xObj.is() && !xObj->IsEmptyPresObj() )
+ {
+ xObj->SetEmptyPresObj( sal_True );
+ }
+ else
+ {
+ eKind = SDRENDTEXTEDIT_UNCHANGED;
+ }
+ }
+ else if( xObj.is() && xObj->IsEmptyPresObj() )
+ {
+ SdrTextObj* pObj = dynamic_cast< SdrTextObj* >( xObj.get() );
+ if( pObj && pObj->HasText() )
+ {
+ SdrPage* pPage = pObj->GetPage();
+ if( !pPage || !pPage->IsMasterPage() )
+ pObj->SetEmptyPresObj( sal_False );
+ }
+ }
+
+ GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(sd::tools::EventMultiplexerEvent::EID_END_TEXT_EDIT, (void*)xObj.get() );
+
+ if( xObj.is() )
+ {
+ SdPage* pPage = dynamic_cast< SdPage* >( xObj->GetPage() );
+ if( pPage )
+ pPage->onEndTextEdit( xObj.get() );
+ }
+
+ return(eKind);
+}
+
+// --------------------------------------------------------------------
+
+/** restores the default text if the given text object is currently in edit mode and
+ no text has been entered already. Is only usefull just before text edit ends. */
+bool View::RestoreDefaultText( SdrTextObj* pTextObj )
+{
+ bool bRestored = false;
+
+ if( pTextObj && (pTextObj == GetTextEditObject()) )
+ {
+ if( !pTextObj->HasText() )
+ {
+ SdPage* pPage = dynamic_cast< SdPage* >( pTextObj->GetPage() );
+
+ if(pPage)
+ {
+ bRestored = pPage->RestoreDefaultText( pTextObj );
+ if( bRestored )
+ {
+ SdrOutliner* pOutliner = GetTextEditOutliner();
+ pTextObj->SetTextEditOutliner( pOutliner );
+ OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
+ if (pOutliner)
+ pOutliner->SetText(*pParaObj);
+ }
+ }
+ }
+ }
+
+ return bRestored;
+}
+
+/*************************************************************************
+|*
+|* Originalgroesse der markierten Objekte setzen
+|*
+\************************************************************************/
+
+void View::SetMarkedOriginalSize()
+{
+ SdrUndoGroup* pUndoGroup = new SdrUndoGroup(*mpDoc);
+ sal_uLong nCount = GetMarkedObjectCount();
+ sal_Bool bOK = sal_False;
+
+ for( sal_uInt32 i = 0; i < nCount; i++ )
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(i);
+
+ if( pObj->GetObjInventor() == SdrInventor )
+ {
+ if( pObj->GetObjIdentifier() == OBJ_OLE2 )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj = ((SdrOle2Obj*)pObj)->GetObjRef();
+ if( xObj.is() )
+ {
+ // TODO/LEAN: working with VisualArea can switch object to running state
+
+ sal_Int64 nAspect = ((SdrOle2Obj*)pObj)->GetAspect();
+ Size aOleSize;
+
+ if ( nAspect == embed::Aspects::MSOLE_ICON )
+ {
+ MapMode aMap100( MAP_100TH_MM );
+ aOleSize = ((SdrOle2Obj*)pObj)->GetOrigObjSize( &aMap100 );
+ bOK = sal_True;
+ }
+ else
+ {
+ MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
+ try
+ {
+ awt::Size aSz = xObj->getVisualAreaSize( nAspect );
+ aOleSize = OutputDevice::LogicToLogic( Size( aSz.Width, aSz.Height ), aUnit, MAP_100TH_MM );
+ bOK = sal_True;
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {}
+ }
+
+ if ( bOK )
+ {
+ Rectangle aDrawRect( pObj->GetLogicRect() );
+
+ pUndoGroup->AddAction( mpDoc->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
+ pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ),
+ Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) );
+ }
+ }
+ }
+ else if( pObj->GetObjIdentifier() == OBJ_GRAF )
+ {
+ const MapMode aMap100( MAP_100TH_MM );
+ Size aSize;
+
+ if ( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode().GetMapUnit() == MAP_PIXEL )
+ aSize = Application::GetDefaultDevice()->PixelToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(), aMap100 );
+ else
+ {
+ aSize = OutputDevice::LogicToLogic( static_cast< SdrGrafObj* >( pObj )->GetGrafPrefSize(),
+ static_cast< SdrGrafObj* >( pObj )->GetGrafPrefMapMode(),
+ aMap100 );
+ }
+
+ pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) );
+ Rectangle aRect( pObj->GetLogicRect() );
+ aRect.SetSize( aSize );
+ pObj->SetLogicRect( aRect );
+
+ bOK = sal_True;
+ }
+ }
+ }
+
+ if( bOK )
+ {
+ pUndoGroup->SetComment( String(SdResId(STR_UNDO_ORIGINALSIZE)) );
+ mpDocSh->GetUndoManager()->AddUndoAction(pUndoGroup);
+ }
+ else
+ delete pUndoGroup;
+}
+
+/*************************************************************************
+|*
+|* OLE-Obj am Client connecten
+|*
+\************************************************************************/
+
+void View::DoConnect(SdrOle2Obj* pObj)
+{
+ if (mpViewSh)
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
+ if( xObj.is() )
+ {
+ ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
+ SfxInPlaceClient* pSdClient = mpViewSh-> GetViewShellBase().FindIPClient( xObj, pWindow );
+ if ( !pSdClient )
+ {
+ pSdClient = new Client(pObj, mpViewSh, pWindow);
+ Rectangle aRect = pObj->GetLogicRect();
+ {
+ // TODO/LEAN: working with visual area can switch object to running state
+ Size aDrawSize = aRect.GetSize();
+ awt::Size aSz;
+
+ MapMode aMapMode( mpDoc->GetScaleUnit() );
+ Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
+
+ Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() );
+ Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
+ aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
+ aScaleHeight.ReduceInaccurate(10);
+ pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
+
+ // sichtbarer Ausschnitt wird nur inplace veraendert!
+ // the object area must be set after the scaling, since it triggers resize
+ aRect.SetSize(aObjAreaSize);
+ pSdClient->SetObjArea(aRect);
+ }
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+sal_Bool View::IsMorphingAllowed() const
+{
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ sal_Bool bRet = sal_False;
+
+ if ( rMarkList.GetMarkCount() == 2 )
+ {
+ const SdrObject* pObj1 = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+ const SdrObject* pObj2 = rMarkList.GetMark( 1 )->GetMarkedSdrObj();
+ const sal_uInt16 nKind1 = pObj1->GetObjIdentifier();
+ const sal_uInt16 nKind2 = pObj2->GetObjIdentifier();
+
+ if ( ( nKind1 != OBJ_TEXT && nKind2 != OBJ_TEXT ) &&
+ ( nKind1 != OBJ_TITLETEXT && nKind2 != OBJ_TITLETEXT ) &&
+ ( nKind1 != OBJ_OUTLINETEXT && nKind2 != OBJ_OUTLINETEXT ) &&
+ ( nKind1 != OBJ_GRUP && nKind2 != OBJ_GRUP ) &&
+ ( nKind1 != OBJ_LINE && nKind2 != OBJ_LINE ) &&
+ ( nKind1 != OBJ_PLIN && nKind2 != OBJ_PLIN ) &&
+ ( nKind1 != OBJ_PATHLINE && nKind2 != OBJ_PATHLINE ) &&
+ ( nKind1 != OBJ_FREELINE && nKind2 != OBJ_FREELINE ) &&
+ ( nKind1 != OBJ_PATHPLIN && nKind2 != OBJ_PATHPLIN ) &&
+ ( nKind1 != OBJ_MEASURE && nKind2 != OBJ_MEASURE ) &&
+ ( nKind1 != OBJ_EDGE && nKind2 != OBJ_EDGE ) &&
+ ( nKind1 != OBJ_GRAF && nKind2 != OBJ_GRAF ) &&
+ ( nKind1 != OBJ_OLE2 && nKind2 != OBJ_OLE2 ) &&
+ ( nKind1 != OBJ_CAPTION && nKind2 != OBJ_CAPTION ) &&
+ !pObj1->ISA( E3dObject) && !pObj2->ISA( E3dObject) )
+ {
+ SfxItemSet aSet1( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
+ SfxItemSet aSet2( mpDoc->GetPool(), XATTR_FILLSTYLE, XATTR_FILLSTYLE );
+
+ aSet1.Put(pObj1->GetMergedItemSet());
+ aSet2.Put(pObj2->GetMergedItemSet());
+
+ const XFillStyle eFillStyle1 = ( (const XFillStyleItem&) aSet1.Get( XATTR_FILLSTYLE ) ).GetValue();
+ const XFillStyle eFillStyle2 = ( (const XFillStyleItem&) aSet2.Get( XATTR_FILLSTYLE ) ).GetValue();
+
+ if( ( eFillStyle1 == XFILL_NONE || eFillStyle1 == XFILL_SOLID ) &&
+ ( eFillStyle2 == XFILL_NONE || eFillStyle2 == XFILL_SOLID ) )
+ bRet = sal_True;
+ }
+ }
+
+ return bRet;
+}
+
+/*************************************************************************
+|*
+|*
+|*
+\************************************************************************/
+
+sal_Bool View::IsVectorizeAllowed() const
+{
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+ sal_Bool bRet = sal_False;
+
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ const SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
+
+ if( pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP )
+ bRet = sal_True;
+ }
+
+ return bRet;
+}
+
+void View::onAccessibilityOptionsChanged()
+{
+ if( mpViewSh )
+ {
+ ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
+ if( pWindow )
+ {
+ const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
+
+ sal_uInt16 nOutputSlot, nPreviewSlot;
+
+ SvtAccessibilityOptions& aAccOptions = getAccessibilityOptions();
+
+ if( mpViewSh->GetViewFrame() && mpViewSh->GetViewFrame()->GetDispatcher() )
+ {
+ if( rStyleSettings.GetHighContrastMode() )
+ {
+ nOutputSlot = SID_OUTPUT_QUALITY_CONTRAST;
+ }
+ else
+ {
+ nOutputSlot = SID_OUTPUT_QUALITY_COLOR;
+ }
+
+ if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
+ {
+ nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
+ }
+ else
+ {
+ nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
+ }
+
+ mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nOutputSlot, SFX_CALLMODE_ASYNCHRON );
+ mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nPreviewSlot, SFX_CALLMODE_ASYNCHRON );
+ }
+
+ mpViewSh->Invalidate();
+ }
+ }
+}
+
+IMPL_LINK( View, OnParagraphInsertedHdl, ::Outliner *, pOutliner )
+{
+ Paragraph* pPara = pOutliner->GetHdlParagraph();
+ SdrObject* pObj = GetTextEditObject();
+
+ if( pPara && pObj )
+ {
+ SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
+ if( pPage )
+ pPage->onParagraphInserted( pOutliner, pPara, pObj );
+ }
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Handler fuer das Loeschen von Seiten (Absaetzen)
+|*
+\************************************************************************/
+
+IMPL_LINK( View, OnParagraphRemovingHdl, ::Outliner *, pOutliner )
+{
+ Paragraph* pPara = pOutliner->GetHdlParagraph();
+ SdrObject* pObj = GetTextEditObject();
+
+ if( pPara && pObj )
+ {
+ SdPage* pPage = dynamic_cast< SdPage* >( pObj->GetPage() );
+ if( pPage )
+ pPage->onParagraphRemoving( pOutliner, pPara, pObj );
+ }
+ return 0;
+}
+
+bool View::isRecordingUndo() const
+{
+ if( mpDoc && mpDoc->IsUndoEnabled() )
+ {
+ sd::UndoManager* pUndoManager = mpDoc ? mpDoc->GetUndoManager() : 0;
+ return pUndoManager && pUndoManager->IsInListAction();
+ }
+ else
+ {
+ return false;
+ }
+}
+
+void View::AddCustomHdl()
+{
+ maSmartTags.addCustomHandles( aHdl );
+}
+
+void View::updateHandles()
+{
+ AdjustMarkHdl();
+}
+
+SdrViewContext View::GetContext() const
+{
+ SdrViewContext eContext = SDRCONTEXT_STANDARD;
+ if( maSmartTags.getContext( eContext ) )
+ return eContext;
+ else
+ return FmFormView::GetContext();
+}
+
+sal_Bool View::HasMarkablePoints() const
+{
+ if( maSmartTags.HasMarkablePoints() )
+ return true;
+ else
+ return FmFormView::HasMarkablePoints();
+}
+
+sal_uLong View::GetMarkablePointCount() const
+{
+ sal_uLong nCount = FmFormView::GetMarkablePointCount();
+ nCount += maSmartTags.GetMarkablePointCount();
+ return nCount;
+}
+
+sal_Bool View::HasMarkedPoints() const
+{
+ if( maSmartTags.HasMarkedPoints() )
+ return true;
+ else
+ return FmFormView::HasMarkedPoints();
+}
+
+sal_uLong View::GetMarkedPointCount() const
+{
+ sal_uLong nCount = FmFormView::GetMarkedPointCount();
+ nCount += maSmartTags.GetMarkedPointCount();
+ return nCount;
+}
+
+sal_Bool View::IsPointMarkable(const SdrHdl& rHdl) const
+{
+ if( maSmartTags.IsPointMarkable( rHdl ) )
+ return true;
+ else
+ return FmFormView::IsPointMarkable( rHdl );
+}
+
+sal_Bool View::MarkPoint(SdrHdl& rHdl, sal_Bool bUnmark )
+{
+ if( maSmartTags.MarkPoint( rHdl, bUnmark ) )
+ return true;
+ else
+ return FmFormView::MarkPoint( rHdl, bUnmark );
+}
+
+sal_Bool View::MarkPoints(const Rectangle* pRect, sal_Bool bUnmark)
+{
+ if( maSmartTags.MarkPoints( pRect, bUnmark ) )
+ return true;
+ else
+ return FmFormView::MarkPoints( pRect, bUnmark );
+}
+
+void View::CheckPossibilities()
+{
+ FmFormView::CheckPossibilities();
+ maSmartTags.CheckPossibilities();
+}
+
+void View::OnBeginPasteOrDrop( PasteOrDropInfos* /*pInfos*/ )
+{
+}
+
+/** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
+ get the correct style sheet. */
+void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfos )
+{
+ SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetTextEditObject() );
+ SdrOutliner* pOutliner = GetTextEditOutliner();
+ if( pOutliner && pTextObj && pTextObj->GetPage() )
+ {
+ SdPage* pPage = static_cast< SdPage* >( pTextObj->GetPage() );
+
+ SfxStyleSheet* pStyleSheet = 0;
+
+ const PresObjKind eKind = pPage->GetPresObjKind(pTextObj);
+ if( eKind != PRESOBJ_NONE )
+ pStyleSheet = pPage->GetStyleSheetForPresObj(eKind);
+ else
+ pStyleSheet = pTextObj->GetStyleSheet();
+
+ if( eKind == PRESOBJ_OUTLINE )
+ {
+ // for outline shapes, set the correct outline style sheet for each
+ // new paragraph, depending on the paragraph depth
+ SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
+
+ for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
+ {
+ sal_Int16 nDepth = pOutliner->GetDepth( nPara );
+
+ SfxStyleSheet* pStyle = 0;
+ if( nDepth > 0 )
+ {
+ String aStyleSheetName( pStyleSheet->GetName() );
+ aStyleSheetName.Erase( aStyleSheetName.Len() - 1, 1 );
+ aStyleSheetName += String::CreateFromInt32( nDepth );
+ pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pStyleSheet->GetFamily() ) );
+ DBG_ASSERT( pStyle, "sd::View::OnEndPasteOrDrop(), Style not found!" );
+ }
+
+ if( !pStyle )
+ pStyle = pStyleSheet;
+
+ pOutliner->SetStyleSheet( nPara, pStyle );
+ }
+ }
+ else
+ {
+ // just put the object style on each new paragraph
+ for ( sal_uInt16 nPara = pInfos->nStartPara; nPara <= pInfos->nEndPara; nPara++ )
+ {
+ pOutliner->SetStyleSheet( nPara, pStyleSheet );
+ }
+ }
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/sdview2.cxx b/sd/source/ui/view/sdview2.cxx
new file mode 100755
index 000000000000..73f48323312f
--- /dev/null
+++ b/sd/source/ui/view/sdview2.cxx
@@ -0,0 +1,1038 @@
+/*************************************************************************
+ *
+ * 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 "View.hxx"
+
+#include <vector>
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <tools/ref.hxx>
+#include <tools/urlobj.hxx>
+#ifndef _MSGBOX_HXX //autogen
+#include <vcl/msgbox.hxx>
+#endif
+#include <svx/svdetc.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdograf.hxx>
+#include <vcl/graph.hxx>
+#include <svx/xexch.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <sfx2/docfile.hxx>
+#include <sfx2/childwin.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/svdpagv.hxx>
+#include <svl/urlbmk.hxx>
+#include <svl/urlbmk.hxx>
+#include <editeng/outliner.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/dbexch.hrc>
+#include <sot/formats.hxx>
+#include <editeng/editeng.hxx>
+#include <svx/svditer.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/scene3d.hxx>
+
+#include <sfx2/objsh.hxx>
+#include <svtools/embedtransfer.hxx>
+
+#include "navigatr.hxx"
+#include "anminfo.hxx"
+#include "strings.hrc"
+#include "glob.hrc"
+#include "sdxfer.hxx"
+#include "sdresid.hxx"
+#include "sdmod.hxx"
+#include "DrawViewShell.hxx"
+#include "DrawDocShell.hxx"
+#include "fudraw.hxx"
+#include "drawdoc.hxx"
+#include "Window.hxx"
+#include "sdpage.hxx"
+#include "unoaprms.hxx"
+#include "drawview.hxx"
+#include "helpids.h"
+#include <vcl/svapp.hxx>
+
+#include "slideshow.hxx"
+
+namespace sd {
+
+#ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
+#define SO2_DECL_SVINPLACEOBJECT_DEFINED
+SO2_DECL_REF(SvInPlaceObject)
+#endif
+#ifndef SO2_DECL_SVSTORAGE_DEFINED
+#define SO2_DECL_SVSTORAGE_DEFINED
+SO2_DECL_REF(SvStorage)
+#endif
+
+using namespace ::com::sun::star;
+
+// ------------------------
+// - SdNavigatorDropEvent -
+// ------------------------
+
+struct SdNavigatorDropEvent : public ExecuteDropEvent
+{
+ DropTargetHelper& mrTargetHelper;
+ ::sd::Window* mpTargetWindow;
+ sal_uInt16 mnPage;
+ sal_uInt16 mnLayer;
+
+ SdNavigatorDropEvent (
+ const ExecuteDropEvent& rEvt,
+ DropTargetHelper& rTargetHelper,
+ ::sd::Window* pTargetWindow,
+ sal_uInt16 nPage,
+ sal_uInt16 nLayer )
+ : ExecuteDropEvent( rEvt ),
+ mrTargetHelper( rTargetHelper ),
+ mpTargetWindow( pTargetWindow ),
+ mnPage( nPage ),
+ mnLayer( nLayer )
+ {}
+};
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > View::CreateClipboardDataObject( View*, ::Window& )
+{
+ // since SdTransferable::CopyToClipboard is called, this
+ // dynamically created object ist destroyed automatically
+ SdTransferable* pTransferable = new SdTransferable( mpDoc, NULL, sal_False );
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRet( pTransferable );
+
+ SD_MOD()->pTransferClip = pTransferable;
+
+ mpDoc->CreatingDataObj( pTransferable );
+ pTransferable->SetWorkDocument( (SdDrawDocument*) GetAllMarkedModel() );
+ mpDoc->CreatingDataObj( NULL );
+
+ const Rectangle aMarkRect( GetAllMarkedRect() );
+ TransferableObjectDescriptor aObjDesc;
+ String aDisplayName;
+ SdrOle2Obj* pSdrOleObj = NULL;
+ SdrPageView* pPgView = GetSdrPageView();
+ SdPage* pOldPage = pPgView ? ( (SdPage*) pPgView->GetPage() ) : NULL;
+ SdPage* pNewPage = (SdPage*) pTransferable->GetWorkDocument()->GetPage( 0 );
+
+ if( pOldPage )
+ {
+ pNewPage->SetSize( pOldPage->GetSize() );
+ pNewPage->SetLayoutName( pOldPage->GetLayoutName() );
+ }
+
+ if( GetMarkedObjectCount() == 1 )
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex(0);
+
+ if( pObj && pObj->ISA(SdrOle2Obj) && ((SdrOle2Obj*) pObj)->GetObjRef().is() )
+ {
+ // If object has no persistence it must be copied as part of the document
+ try
+ {
+ uno::Reference< embed::XEmbedPersist > xPersObj( ((SdrOle2Obj*)pObj)->GetObjRef(), uno::UNO_QUERY );
+ if ( xPersObj.is() && xPersObj->hasEntry() )
+ pSdrOleObj = (SdrOle2Obj*) pObj;
+ }
+ catch( uno::Exception& )
+ {}
+ }
+ }
+
+ if( pSdrOleObj )
+ SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
+ else
+ pTransferable->GetWorkDocument()->GetDocSh()->FillTransferableObjectDescriptor( aObjDesc );
+
+ if( mpDocSh )
+ aObjDesc.maDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+
+ aObjDesc.maSize = aMarkRect.GetSize();
+
+ pTransferable->SetStartPos( aMarkRect.TopLeft() );
+ pTransferable->SetObjectDescriptor( aObjDesc );
+ pTransferable->CopyToClipboard( mpViewSh->GetActiveWindow() );
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > View::CreateDragDataObject( View* pWorkView, ::Window& rWindow, const Point& rDragPos )
+{
+ SdTransferable* pTransferable = new SdTransferable( mpDoc, pWorkView, sal_False );
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRet( pTransferable );
+
+ SD_MOD()->pTransferDrag = pTransferable;
+
+ TransferableObjectDescriptor aObjDesc;
+ String aDisplayName;
+ SdrOle2Obj* pSdrOleObj = NULL;
+
+ if( GetMarkedObjectCount() == 1 )
+ {
+ SdrObject* pObj = GetMarkedObjectByIndex( 0 );
+
+ if( pObj && pObj->ISA( SdrOle2Obj ) && ( (SdrOle2Obj*) pObj )->GetObjRef().is() )
+ {
+ // If object has no persistence it must be copied as part of the document
+ try
+ {
+ uno::Reference< embed::XEmbedPersist > xPersObj( ((SdrOle2Obj*)pObj)->GetObjRef(), uno::UNO_QUERY );
+ if ( xPersObj.is() && xPersObj->hasEntry() )
+ pSdrOleObj = (SdrOle2Obj*) pObj;
+ }
+ catch( uno::Exception& )
+ {}
+ }
+ }
+
+ if( mpDocSh )
+ aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+
+ if( pSdrOleObj )
+ SvEmbedTransferHelper::FillTransferableObjectDescriptor( aObjDesc, pSdrOleObj->GetObjRef(), pSdrOleObj->GetGraphic(), pSdrOleObj->GetAspect() );
+ else
+ mpDocSh->FillTransferableObjectDescriptor( aObjDesc );
+
+ aObjDesc.maSize = GetAllMarkedRect().GetSize();
+ aObjDesc.maDragStartPos = rDragPos;
+ aObjDesc.maDisplayName = aDisplayName;
+ aObjDesc.mbCanLink = sal_False;
+
+ pTransferable->SetStartPos( rDragPos );
+ pTransferable->SetObjectDescriptor( aObjDesc );
+ pTransferable->StartDrag( &rWindow, DND_ACTION_COPYMOVE | DND_ACTION_LINK );
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > View::CreateSelectionDataObject( View* pWorkView, ::Window& rWindow )
+{
+ SdTransferable* pTransferable = new SdTransferable( mpDoc, pWorkView, sal_True );
+ ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xRet( pTransferable );
+ TransferableObjectDescriptor aObjDesc;
+ const Rectangle aMarkRect( GetAllMarkedRect() );
+ String aDisplayName;
+
+ SD_MOD()->pTransferSelection = pTransferable;
+
+ if( mpDocSh )
+ {
+ aDisplayName = mpDocSh->GetMedium()->GetURLObject().GetURLNoPass();
+ mpDocSh->FillTransferableObjectDescriptor( aObjDesc );
+ }
+
+ aObjDesc.maSize = aMarkRect.GetSize();
+
+ pTransferable->SetStartPos( aMarkRect.TopLeft() );
+ pTransferable->SetObjectDescriptor( aObjDesc );
+ pTransferable->CopyToSelection( &rWindow );
+
+ return xRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void View::UpdateSelectionClipboard( sal_Bool bForceDeselect )
+{
+ if( mpViewSh && mpViewSh->GetActiveWindow() )
+ {
+ if( !bForceDeselect && GetMarkedObjectList().GetMarkCount() )
+ CreateSelectionDataObject( this, *mpViewSh->GetActiveWindow() );
+ else if( SD_MOD()->pTransferSelection && ( SD_MOD()->pTransferSelection->GetView() == this ) )
+ {
+ TransferableHelper::ClearSelection( mpViewSh->GetActiveWindow() );
+ SD_MOD()->pTransferSelection = NULL;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void View::DoCut(::Window* )
+{
+ const OutlinerView* pOLV = GetTextEditOutlinerView();
+
+ if( pOLV )
+ ( (OutlinerView*) pOLV)->Cut();
+ else if( AreObjectsMarked() )
+ {
+ String aStr( SdResId(STR_UNDO_CUT) );
+
+ DoCopy();
+ BegUndo( ( aStr += sal_Unicode(' ') ) += GetDescriptionOfMarkedObjects() );
+ DeleteMarked();
+ EndUndo();
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void View::DoCopy (::Window* pWindow)
+{
+ const OutlinerView* pOLV = GetTextEditOutlinerView();
+
+ if( pOLV )
+ ( (OutlinerView*) pOLV)->Copy();
+ else if( AreObjectsMarked() )
+ {
+ BrkAction();
+ CreateClipboardDataObject( this, *pWindow );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void View::DoPaste (::Window* pWindow)
+{
+ TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpViewSh->GetActiveWindow() ) );
+ if( !aDataHelper.GetTransferable().is() )
+ return; // empty clipboard?
+
+ const OutlinerView* pOLV = GetTextEditOutlinerView();
+
+ if( pOLV && EditEngine::HasValidData( aDataHelper.GetTransferable() ) )
+ {
+ const_cast< OutlinerView* >(pOLV)->PasteSpecial();
+
+ SdrObject* pObj = GetTextEditObject();
+ SdPage* pPage = (SdPage*)( pObj ? pObj->GetPage() : NULL );
+ ::Outliner* pOutliner = pOLV->GetOutliner();
+
+ if( pOutliner)
+ {
+ if( pObj && pPage && pPage->GetPresObjKind(pObj) == PRESOBJ_TITLE )
+ {
+ // remove all hard linebreaks from the title
+ if( pOutliner && pOutliner->GetParagraphCount() > 1 )
+ {
+ sal_Bool bOldUpdateMode = pOutliner->GetUpdateMode();
+
+ pOutliner->SetUpdateMode( sal_False );
+
+ const EditEngine& rEdit = pOutliner->GetEditEngine();
+ const int nParaCount = rEdit.GetParagraphCount();
+
+ for( int nPara = nParaCount - 2; nPara >= 0; nPara-- )
+ {
+ const sal_uInt16 nParaLen = (sal_uInt16)rEdit.GetTextLen( (sal_uInt16)nPara );
+ pOutliner->QuickDelete( ESelection( (sal_uInt16)nPara, nParaLen, (sal_uInt16)nPara+1, 0 ) );
+ pOutliner->QuickInsertLineBreak( ESelection( (sal_uInt16)nPara, nParaLen, (sal_uInt16)nPara, nParaLen ) );
+ }
+
+ DBG_ASSERT( rEdit.GetParagraphCount() <= 1, "Titelobjekt contains hard line breaks" );
+ pOutliner->SetUpdateMode(bOldUpdateMode);
+ }
+ }
+
+ if( !mpDoc->IsChanged() )
+ {
+ if( pOutliner && pOutliner->IsModified() )
+ mpDoc->SetChanged( sal_True );
+ }
+ }
+ }
+ else
+ {
+ Point aPos;
+ sal_Int8 nDnDAction = DND_ACTION_COPY;
+
+ if( pWindow )
+ aPos = pWindow->PixelToLogic( Rectangle( aPos, pWindow->GetOutputSizePixel() ).Center() );
+
+ DrawViewShell* pDrViewSh = (DrawViewShell*) mpDocSh->GetViewShell();
+
+ if (pDrViewSh != NULL)
+ {
+ if( !InsertData( aDataHelper, aPos, nDnDAction, sal_False ) )
+ {
+ INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
+
+ if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
+ ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
+ ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
+ {
+ pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void View::StartDrag( const Point& rStartPos, ::Window* pWindow )
+{
+ if( AreObjectsMarked() && IsAction() && mpViewSh && pWindow && !mpDragSrcMarkList )
+ {
+ BrkAction();
+
+ if( IsTextEdit() )
+ SdrEndTextEdit();
+
+ DrawViewShell* pDrawViewShell = dynamic_cast< DrawViewShell* >( mpDocSh ? mpDocSh->GetViewShell() : 0 );
+
+ if( pDrawViewShell )
+ {
+ FunctionReference xFunction( pDrawViewShell->GetCurrentFunction() );
+
+ if( xFunction.is() && xFunction->ISA( FuDraw ) )
+ static_cast<FuDraw*>(xFunction.get())->ForcePointer( NULL );
+ }
+
+ mpDragSrcMarkList = new SdrMarkList(GetMarkedObjectList());
+ mnDragSrcPgNum = GetSdrPageView()->GetPage()->GetPageNum();
+
+ if( IsUndoEnabled() )
+ {
+ String aStr( SdResId(STR_UNDO_DRAGDROP) );
+ aStr += sal_Unicode(' ');
+ aStr += mpDragSrcMarkList->GetMarkDescription();
+ BegUndo(aStr);
+ }
+ CreateDragDataObject( this, *pWindow, rStartPos );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void View::DragFinished( sal_Int8 nDropAction )
+{
+ const bool bUndo = IsUndoEnabled();
+
+ SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
+
+ if( pDragTransferable )
+ pDragTransferable->SetView( NULL );
+
+ if( ( nDropAction & DND_ACTION_MOVE ) &&
+ pDragTransferable && !pDragTransferable->IsInternalMove() &&
+ mpDragSrcMarkList && mpDragSrcMarkList->GetMarkCount() &&
+ !IsPresObjSelected() )
+ {
+ mpDragSrcMarkList->ForceSort();
+
+ if( bUndo )
+ BegUndo();
+
+ sal_uLong nm, nAnz = mpDragSrcMarkList->GetMarkCount();
+
+ for( nm = nAnz; nm>0; )
+ {
+ nm--;
+ SdrMark* pM=mpDragSrcMarkList->GetMark(nm);
+ if( bUndo )
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pM->GetMarkedSdrObj()));
+ }
+
+ mpDragSrcMarkList->GetMark(0)->GetMarkedSdrObj()->GetOrdNum();
+
+ for (nm=nAnz; nm>0;)
+ {
+ nm--;
+ SdrMark* pM=mpDragSrcMarkList->GetMark(nm);
+ SdrObject* pObj=pM->GetMarkedSdrObj();
+ sal_uInt32 nOrdNum=pObj->GetOrdNumDirect();
+
+ if( pObj && pObj->GetPage() )
+ {
+#ifdef DBG_UTIL
+ SdrObject* pChkObj =
+#endif
+ pObj->GetPage()->RemoveObject(nOrdNum);
+ DBG_ASSERT(pChkObj==pObj,"pChkObj!=pObj beim RemoveObject()");
+ }
+ }
+
+ if( bUndo )
+ EndUndo();
+ }
+
+ if( pDragTransferable )
+ pDragTransferable->SetInternalMove( sal_False );
+
+ if( bUndo )
+ EndUndo();
+ mnDragSrcPgNum = SDRPAGE_NOTFOUND;
+ delete mpDragSrcMarkList;
+ mpDragSrcMarkList = NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int8 View::AcceptDrop( const AcceptDropEvent& rEvt, DropTargetHelper& rTargetHelper,
+ ::sd::Window*, sal_uInt16, sal_uInt16 nLayer )
+{
+ String aLayerName( GetActiveLayer() );
+ SdrPageView* pPV = GetSdrPageView();
+ sal_Int8 nDropAction = rEvt.mnAction;
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( nLayer != SDRLAYER_NOTFOUND )
+ {
+ SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
+ aLayerName = rLayerAdmin.GetLayerPerID(nLayer)->GetName();
+ }
+
+ if( mbIsDropAllowed && !pPV->IsLayerLocked( aLayerName ) && pPV->IsLayerVisible( aLayerName ) )
+ {
+ const OutlinerView* pOLV = GetTextEditOutlinerView();
+ sal_Bool bIsInsideOutlinerView = sal_False;
+
+ if( pOLV )
+ {
+ Rectangle aRect( pOLV->GetOutputArea() );
+
+ if (GetMarkedObjectCount() == 1)
+ {
+ SdrMark* pMark = GetSdrMarkByIndex(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ aRect.Union( pObj->GetLogicRect() );
+ }
+
+ if( aRect.IsInside( pOLV->GetWindow()->PixelToLogic( rEvt.maPosPixel ) ) )
+ {
+ bIsInsideOutlinerView = sal_True;
+ }
+ }
+
+ if( !bIsInsideOutlinerView )
+ {
+ SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
+
+ if( pDragTransferable )
+ {
+ const View* pSourceView = pDragTransferable->GetView();
+
+ if( pDragTransferable->IsPageTransferable() )
+ {
+ nRet = DND_ACTION_COPY;
+ }
+ else if( pSourceView )
+ {
+ if( !( nDropAction & DND_ACTION_LINK ) ||
+ pSourceView->GetDocSh()->GetMedium()->GetName().Len() )
+ {
+ nRet = nDropAction;
+ }
+ }
+ }
+ else
+ {
+ const sal_Bool bDrawing = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_DRAWING );
+ const sal_Bool bGraphic = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_SVXB );
+ const sal_Bool bMtf = rTargetHelper.IsDropFormatSupported( FORMAT_GDIMETAFILE );
+ const sal_Bool bBitmap = rTargetHelper.IsDropFormatSupported( FORMAT_BITMAP );
+ sal_Bool bBookmark = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK );
+ sal_Bool bXFillExchange = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_XFA );
+
+ // check handle insert
+ if( !nRet && ( (bXFillExchange && ( SDRDRAG_GRADIENT == GetDragMode() )) || ( SDRDRAG_TRANSPARENCE == GetDragMode() ) ) )
+ {
+ const SdrHdlList& rHdlList = GetHdlList();
+
+ for( sal_uInt32 n = 0; n < rHdlList.GetHdlCount(); n++ )
+ {
+ SdrHdl* pIAOHandle = rHdlList.GetHdl( n );
+
+ if( pIAOHandle && ( HDL_COLR == pIAOHandle->GetKind() ) )
+ {
+ if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
+ {
+ nRet = nDropAction;
+ static_cast< SdrHdlColor* >( pIAOHandle )->SetSize( SDR_HANDLE_COLOR_SIZE_SELECTED );
+ }
+ else
+ {
+ static_cast< SdrHdlColor* >( pIAOHandle )->SetSize( SDR_HANDLE_COLOR_SIZE_NORMAL );
+ }
+ }
+ }
+ }
+
+ // check object insert
+ if( !nRet && ( bXFillExchange || ( ( bDrawing || bGraphic || bMtf || bBitmap || bBookmark ) && ( nDropAction & DND_ACTION_LINK ) ) ) )
+ {
+ SdrObject* pPickObj = NULL;
+ SdrPageView* pPageView = NULL;
+ ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
+ Point aPos( pWindow->PixelToLogic( rEvt.maPosPixel ) );
+ const sal_Bool bHasPickObj = PickObj( aPos, getHitTolLog(), pPickObj, pPageView );
+ sal_Bool bIsPresTarget = sal_False;
+
+ if( bHasPickObj && pPickObj && ( pPickObj->IsEmptyPresObj() || pPickObj->GetUserCall() ) )
+ {
+ SdPage* pPage = (SdPage*) pPickObj->GetPage();
+
+ if( pPage && pPage->IsMasterPage() )
+ bIsPresTarget = pPage->IsPresObj( pPickObj );
+ }
+
+ if( bHasPickObj && !bIsPresTarget &&
+ ( !pPickObj->ISA( SdrGrafObj ) || bGraphic || bMtf || bBitmap || ( bXFillExchange && !pPickObj->ISA( SdrGrafObj ) && !pPickObj->ISA( SdrOle2Obj ) ) ) )
+ {
+ if( mpDropMarkerObj != pPickObj )
+ {
+ mpDropMarkerObj = pPickObj;
+ ImplClearDrawDropMarker();
+
+ if(mpDropMarkerObj)
+ {
+ mpDropMarker = new SdrDropMarkerOverlay(*this, *mpDropMarkerObj);
+ }
+ }
+
+ nRet = nDropAction;
+ }
+ else
+ bXFillExchange = sal_False;
+ }
+
+ // check normal insert
+ if( !nRet )
+ {
+ const sal_Bool bSBAFormat = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_SVX_FORMFIELDEXCH );
+ const sal_Bool bEditEngine = rTargetHelper.IsDropFormatSupported( SOT_FORMATSTR_ID_EDITENGINE );
+ const sal_Bool bString = rTargetHelper.IsDropFormatSupported( FORMAT_STRING );
+ const sal_Bool bRTF = rTargetHelper.IsDropFormatSupported( FORMAT_RTF );
+ const sal_Bool bFile = rTargetHelper.IsDropFormatSupported( FORMAT_FILE );
+ const sal_Bool bFileList = rTargetHelper.IsDropFormatSupported( FORMAT_FILE_LIST );
+
+ if( mpDropMarker )
+ {
+ ImplClearDrawDropMarker();
+ mpDropMarkerObj = NULL;
+ }
+
+ if( bBookmark && bFile && ( nDropAction & DND_ACTION_MOVE ) && mpViewSh && SlideShow::IsRunning(mpViewSh->GetViewShellBase()) )
+ bBookmark = sal_False;
+
+ if( bDrawing || bGraphic || bMtf || bBitmap || bBookmark || bFile || bFileList || bXFillExchange || bSBAFormat || bEditEngine || bString || bRTF )
+ nRet = nDropAction;
+
+ // For entries from the navigator, change action copy.
+ if (bBookmark
+ && rTargetHelper.IsDropFormatSupported(
+ SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId())
+ && (nDropAction & DND_ACTION_MOVE)!=0)
+ {
+ nRet = DND_ACTION_COPY;
+ }
+ }
+ }
+ }
+ }
+
+ // destroy drop marker if this is a leaving event
+ if( rEvt.mbLeaving && mpDropMarker )
+ {
+ ImplClearDrawDropMarker();
+ mpDropMarkerObj = NULL;
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Int8 View::ExecuteDrop( const ExecuteDropEvent& rEvt, DropTargetHelper& rTargetHelper,
+ ::sd::Window* pTargetWindow, sal_uInt16 nPage, sal_uInt16 nLayer )
+{
+ SdrPageView* pPV = GetSdrPageView();
+ String aActiveLayer = GetActiveLayer();
+ sal_Int8 nDropAction = rEvt.mnAction;
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ // destroy drop marker if it is shown
+ if( mpDropMarker )
+ {
+ ImplClearDrawDropMarker();
+ mpDropMarkerObj = NULL;
+ }
+
+ if( !pPV->IsLayerLocked( aActiveLayer ) )
+ {
+ const OutlinerView* pOLV = GetTextEditOutlinerView();
+ sal_Bool bIsInsideOutlinerView = sal_False;
+
+ if( pOLV )
+ {
+ Rectangle aRect( pOLV->GetOutputArea() );
+
+ if( GetMarkedObjectCount() == 1 )
+ {
+ SdrMark* pMark = GetSdrMarkByIndex(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+ aRect.Union( pObj->GetLogicRect() );
+ }
+
+ Point aPos( pOLV->GetWindow()->PixelToLogic( rEvt.maPosPixel ) );
+
+ if( aRect.IsInside( aPos ) )
+ {
+ bIsInsideOutlinerView = sal_True;
+ }
+ }
+
+ if( !bIsInsideOutlinerView )
+ {
+ Point aPos;
+ TransferableDataHelper aDataHelper( rEvt.maDropEvent.Transferable );
+
+ if( pTargetWindow )
+ aPos = pTargetWindow->PixelToLogic( rEvt.maPosPixel );
+
+ // handle insert?
+ if( (!nRet && ( SDRDRAG_GRADIENT == GetDragMode() )) || (( SDRDRAG_TRANSPARENCE == GetDragMode() ) && aDataHelper.HasFormat( SOT_FORMATSTR_ID_XFA )) )
+ {
+ const SdrHdlList& rHdlList = GetHdlList();
+
+ for( sal_uInt32 n = 0; !nRet && n < rHdlList.GetHdlCount(); n++ )
+ {
+ SdrHdl* pIAOHandle = rHdlList.GetHdl( n );
+
+ if( pIAOHandle && ( HDL_COLR == pIAOHandle->GetKind() ) )
+ {
+ if(pIAOHandle->getOverlayObjectList().isHitPixel(rEvt.maPosPixel))
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_XFA, xStm ) && xStm.Is() )
+ {
+ XFillExchangeData aFillData( XFillAttrSetItem( &mpDoc->GetPool() ) );
+
+ *xStm >> aFillData;
+ const Color aColor( ( (XFillColorItem&) aFillData.GetXFillAttrSetItem()->GetItemSet().Get( XATTR_FILLCOLOR ) ).GetColorValue() );
+ static_cast< SdrHdlColor* >( pIAOHandle )->SetColor( aColor, sal_True );
+ nRet = nDropAction;
+ }
+ }
+ }
+ }
+ }
+
+ // standard insert?
+ if( !nRet && InsertData( aDataHelper, aPos, nDropAction, sal_True, 0, nPage, nLayer ) )
+ nRet = nDropAction;
+
+ // special insert?
+ if( !nRet && mpViewSh )
+ {
+ String aTmpString1, aTmpString2;
+ INetBookmark aINetBookmark( aTmpString1, aTmpString2 );
+
+ // insert bookmark
+ if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
+ aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) )
+ {
+ SdPageObjsTLB::SdPageObjsTransferable* pPageObjsTransferable = SdPageObjsTLB::SdPageObjsTransferable::getImplementation( aDataHelper.GetXTransferable() );
+
+ if( pPageObjsTransferable &&
+ ( NAVIGATOR_DRAGTYPE_LINK == pPageObjsTransferable->GetDragType() ||
+ NAVIGATOR_DRAGTYPE_EMBEDDED == pPageObjsTransferable->GetDragType() ) )
+ {
+ // insert bookmark from own navigator (handled async. due to possible message box )
+ Application::PostUserEvent( LINK( this, View, ExecuteNavigatorDrop ),
+ new SdNavigatorDropEvent( rEvt, rTargetHelper, pTargetWindow,
+ nPage, nLayer ) );
+ nRet = nDropAction;
+ }
+ else
+ {
+ SdrObject* pPickObj = NULL;
+ SdrPageView* pPageView = NULL;
+
+ if( PickObj( aPos, getHitTolLog(), pPickObj, pPageView ) )
+ {
+ // insert as clip action => jump
+ rtl::OUString aBookmark( aINetBookmark.GetURL() );
+ SdAnimationInfo* pInfo = mpDoc->GetAnimationInfo( pPickObj );
+ sal_Bool bCreated = sal_False;
+
+ if( aBookmark.getLength() )
+ {
+ presentation::ClickAction eClickAction = presentation::ClickAction_DOCUMENT;
+
+ sal_Int32 nIndex = aBookmark.indexOf( (sal_Unicode)'#' );
+ if( nIndex != -1 )
+ {
+ const String aDocName( aBookmark.copy( 0, nIndex ) );
+
+ if( mpDocSh->GetMedium()->GetName() == aDocName || mpDocSh->GetName() == aDocName )
+ {
+ // internal jump, only use the part after and including '#'
+ eClickAction = presentation::ClickAction_BOOKMARK;
+ aBookmark = aBookmark.copy( nIndex+1 );
+ }
+ }
+
+ if( !pInfo )
+ {
+ pInfo = SdDrawDocument::GetShapeUserData( *pPickObj, true );
+ bCreated = sal_True;
+ }
+
+ // Undo-Action mit alten und neuen Groessen erzeugen
+ SdAnimationPrmsUndoAction* pAction = new SdAnimationPrmsUndoAction(mpDoc, pPickObj, bCreated);
+ pAction->SetActive(pInfo->mbActive, pInfo->mbActive);
+ pAction->SetEffect(pInfo->meEffect, pInfo->meEffect);
+ pAction->SetTextEffect(pInfo->meTextEffect, pInfo->meTextEffect);
+ pAction->SetSpeed(pInfo->meSpeed, pInfo->meSpeed);
+ pAction->SetDim(pInfo->mbDimPrevious, pInfo->mbDimPrevious);
+ pAction->SetDimColor(pInfo->maDimColor, pInfo->maDimColor);
+ pAction->SetDimHide(pInfo->mbDimHide, pInfo->mbDimHide);
+ pAction->SetSoundOn(pInfo->mbSoundOn, pInfo->mbSoundOn);
+ pAction->SetSound(pInfo->maSoundFile, pInfo->maSoundFile);
+ pAction->SetPlayFull(pInfo->mbPlayFull, pInfo->mbPlayFull);
+ pAction->SetPathObj(pInfo->mpPathObj, pInfo->mpPathObj);
+ pAction->SetClickAction(pInfo->meClickAction, eClickAction);
+ pAction->SetBookmark(pInfo->GetBookmark(), aBookmark);
+// pAction->SetInvisibleInPres(pInfo->mbInvisibleInPresentation, sal_True);
+ pAction->SetVerb(pInfo->mnVerb, pInfo->mnVerb);
+ pAction->SetSecondEffect(pInfo->meSecondEffect, pInfo->meSecondEffect);
+ pAction->SetSecondSpeed(pInfo->meSecondSpeed, pInfo->meSecondSpeed);
+ pAction->SetSecondSoundOn(pInfo->mbSecondSoundOn, pInfo->mbSecondSoundOn);
+ pAction->SetSecondPlayFull(pInfo->mbSecondPlayFull, pInfo->mbSecondPlayFull);
+
+ String aString(SdResId(STR_UNDO_ANIMATION));
+ pAction->SetComment(aString);
+ mpDocSh->GetUndoManager()->AddUndoAction(pAction);
+ pInfo->meClickAction = eClickAction;
+ pInfo->SetBookmark( aBookmark );
+ mpDoc->SetChanged();
+
+ nRet = nDropAction;
+ }
+ }
+ else if( mpViewSh->ISA( DrawViewShell ) )
+ {
+ // insert as normal URL button
+ ( (DrawViewShell*) mpViewSh )->InsertURLButton( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), String(), &aPos );
+ nRet = nDropAction;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return nRet;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( View, ExecuteNavigatorDrop, SdNavigatorDropEvent*, pSdNavigatorDropEvent )
+{
+ TransferableDataHelper aDataHelper( pSdNavigatorDropEvent->maDropEvent.Transferable );
+ SdPageObjsTLB::SdPageObjsTransferable* pPageObjsTransferable = SdPageObjsTLB::SdPageObjsTransferable::getImplementation( aDataHelper.GetXTransferable() );
+ INetBookmark aINetBookmark;
+
+ if( pPageObjsTransferable && aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) )
+ {
+ Point aPos;
+ List aBookmarkList;
+ String aBookmark;
+ SdPage* pPage = (SdPage*) GetSdrPageView()->GetPage();
+ sal_uInt16 nPgPos = 0xFFFF;
+
+ if( pSdNavigatorDropEvent->mpTargetWindow )
+ aPos = pSdNavigatorDropEvent->mpTargetWindow->PixelToLogic( pSdNavigatorDropEvent->maPosPixel );
+
+ const rtl::OUString aURL( aINetBookmark.GetURL() );
+ sal_Int32 nIndex = aURL.indexOf( (sal_Unicode)'#' );
+ if( nIndex != -1 )
+ aBookmark = aURL.copy( nIndex+1 );
+ aBookmarkList.Insert( &aBookmark );
+
+ if( !pPage->IsMasterPage() )
+ {
+ if( pPage->GetPageKind() == PK_STANDARD )
+ nPgPos = pPage->GetPageNum() + 2;
+ else if( pPage->GetPageKind() == PK_NOTES )
+ nPgPos = pPage->GetPageNum() + 1;
+ }
+
+ // Um zu gewaehrleisten, dass alle Seitennamen eindeutig sind, werden
+ // die einzufuegenden geprueft und gegebenenfalls in einer Ersatzliste
+ // aufgenommen (bNameOK == sal_False -> Benutzer hat abgebrochen)
+ List* pExchangeList = NULL;
+ sal_Bool bLink = ( NAVIGATOR_DRAGTYPE_LINK == pPageObjsTransferable->GetDragType() ? sal_True : sal_False );
+ sal_Bool bNameOK = GetExchangeList( pExchangeList, &aBookmarkList, 2 );
+ sal_Bool bReplace = sal_False;
+
+ // Da man hier nicht weiss, ob es sich um eine Seite oder ein Objekt handelt,
+ // wird eine Liste sowohl mit Seiten, als auch mit Objekten gefuellt.
+ // Sollten Seitennamen und Objektnamen identisch sein gibt es hier natuerlich Probleme !!!
+ if( bNameOK )
+ {
+ mpDoc->InsertBookmark( &aBookmarkList, pExchangeList,
+ bLink, bReplace, nPgPos, sal_False,
+ &pPageObjsTransferable->GetDocShell(),
+ sal_True, &aPos );
+ }
+
+ // Loeschen der ExchangeList
+ if( pExchangeList )
+ {
+ for( void* p = pExchangeList->First(); p; p = pExchangeList->Next() )
+ delete (String*) p;
+
+ delete pExchangeList;
+ }
+ }
+
+ delete pSdNavigatorDropEvent;
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Rueckgabeparameter:
+|* pExchangeList == NULL -> Namen sind alle eindeutig
+|* bNameOK == sal_False -> Benutzer hat abgebrochen
+|* nType == 0 -> Seiten
+|* nType == 1 -> Objekte
+|* nType == 2 -> Seiten + Objekte
+|*
+\************************************************************************/
+
+sal_Bool View::GetExchangeList( List*& rpExchangeList, List* pBookmarkList, sal_uInt16 nType )
+{
+ DBG_ASSERT( !rpExchangeList, "ExchangeList muss NULL sein!");
+
+ sal_Bool bListIdentical = sal_True; // BookmarkList und ExchangeList sind gleich
+ sal_Bool bNameOK = sal_True; // Name ist eindeutig
+
+ rpExchangeList = new List();
+
+ if( pBookmarkList )
+ {
+ String* pString = (String*) pBookmarkList->First();
+
+ while( pString && bNameOK )
+ {
+ String* pNewName = new String( *pString );
+
+ if( nType == 0 || nType == 2 )
+ bNameOK = mpDocSh->CheckPageName (
+ mpViewSh->GetActiveWindow(), *pNewName);
+
+ if( bNameOK && ( nType == 1 || nType == 2 ) )
+ {
+ if( mpDoc->GetObj( *pNewName ) )
+ {
+ String aTitle( SdResId( STR_TITLE_NAMEGROUP ) );
+ String aDesc( SdResId( STR_DESC_NAMEGROUP ) );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ AbstractSvxNameDialog* pDlg = pFact ? pFact->CreateSvxNameDialog( mpViewSh->GetActiveWindow(), *pNewName, aDesc ) : 0;
+ if( pDlg )
+ {
+ pDlg->SetEditHelpId( HID_SD_NAMEDIALOG_OBJECT );
+
+ bNameOK = sal_False;
+ pDlg->SetText( aTitle );
+
+ while( !bNameOK && pDlg->Execute() == RET_OK )
+ {
+ pDlg->GetName( *pNewName );
+
+ if( !mpDoc->GetObj( *pNewName ) )
+ bNameOK = sal_True;
+ }
+
+ delete pDlg;
+ }
+ }
+ }
+
+ if( bListIdentical )
+ bListIdentical = ( *pString == *pNewName );
+
+ rpExchangeList->Insert( pNewName, LIST_APPEND );
+ pString = (String*) pBookmarkList->Next();
+ }
+ }
+
+ // ExchangeList ist mit BookmarkList identisch
+ if( rpExchangeList && bListIdentical )
+ {
+ String* pString = (String*) rpExchangeList->First();
+ while( pString )
+ {
+ delete pString;
+ pString = (String*) rpExchangeList->Next();
+ }
+ delete rpExchangeList;
+ rpExchangeList = NULL;
+ }
+
+ return( bNameOK );
+}
+
+typedef std::vector< std::pair< sal_uInt32, sal_uInt32 > > PathSurrogateVector;
+typedef std::vector< SdrObject* > SdrObjectVector;
+
+void ImplProcessObjectList(SdrObject* pObj, SdrObjectVector& rVector )
+{
+ sal_Bool bIsGroup(pObj->IsGroupObject());
+ if(bIsGroup && pObj->ISA(E3dObject) && !pObj->ISA(E3dScene))
+ bIsGroup = sal_False;
+
+ rVector.push_back( pObj );
+
+ if(bIsGroup)
+ {
+ SdrObjList* pObjList = pObj->GetSubList();
+ sal_uInt32 a;
+ for( a = 0; a < pObjList->GetObjCount(); a++)
+ ImplProcessObjectList(pObjList->GetObj(a), rVector);
+ }
+}
+
+SdrModel* View::GetMarkedObjModel() const
+{
+ return FmFormView::GetMarkedObjModel();;
+}
+
+sal_Bool View::Paste(const SdrModel& rMod, const Point& rPos, SdrObjList* pLst /* =NULL */, sal_uInt32 nOptions /* =0 */)
+{
+ return FmFormView::Paste( rMod, rPos, pLst,nOptions );;
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
new file mode 100755
index 000000000000..c7f460758499
--- /dev/null
+++ b/sd/source/ui/view/sdview3.cxx
@@ -0,0 +1,1506 @@
+/*************************************************************************
+ *
+ * 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 "View.hxx"
+#include <com/sun/star/embed/XEmbedObjectClipboardCreator.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <sot/filelist.hxx>
+#include <unotools/pathoptions.hxx>
+#include <editeng/editdata.hxx>
+#include <svl/urlbmk.hxx>
+#include <svx/xexch.hxx>
+#include <svx/xflclit.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/svdpagv.hxx>
+#include <editeng/eeitem.hxx>
+#include <editeng/colritem.hxx>
+#include <sfx2/docfile.hxx>
+#include <svx/svditer.hxx>
+#include <svx/svdogrp.hxx>
+#include <svx/svdoole2.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdetc.hxx>
+#include <svx/svdundo.hxx>
+#include <sfx2/app.hxx>
+#include <svl/itempool.hxx>
+#include <sot/clsids.hxx>
+#include <svx/fmmodel.hxx>
+#include <sot/formats.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editeng.hxx>
+#include <svx/obj3d.hxx>
+#include <svx/e3dundo.hxx>
+#include <svx/dbexch.hrc>
+#include <svx/unomodel.hxx>
+#include <unotools/streamwrap.hxx>
+#include <vcl/metaact.hxx>
+#include <svx/svxids.hrc>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include "DrawDocShell.hxx"
+#include "fupoor.hxx"
+#include "Window.hxx"
+#include "sdxfer.hxx"
+#include "sdpage.hxx"
+#include "DrawViewShell.hxx"
+#include "drawdoc.hxx"
+#include "sdresid.hxx"
+#include "strings.hrc"
+#include "imapinfo.hxx"
+#include "SlideSorterViewShell.hxx"
+#include "strmname.h"
+#include "unomodel.hxx"
+#include "ViewClipboard.hxx"
+
+#include <sfx2/ipclient.hxx>
+#include <comphelper/storagehelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <tools/stream.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <svx/sdrhittesthelper.hxx>
+
+// --------------
+// - Namespaces -
+// --------------
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::datatransfer;
+using namespace ::com::sun::star::datatransfer::clipboard;
+
+namespace sd {
+
+#define CHECK_FORMAT_TRANS( _def_Type ) ( ( nFormat == (_def_Type) || !nFormat ) && aDataHelper.HasFormat( _def_Type ) )
+
+/*************************************************************************
+|*
+|* Paste
+|*
+\************************************************************************/
+
+// #83525#
+struct ImpRememberOrigAndClone
+{
+ SdrObject* pOrig;
+ SdrObject* pClone;
+};
+
+SdrObject* ImpGetClone(Container& aConnectorContainer, SdrObject* pConnObj)
+{
+ for(sal_uInt32 a(0); a < aConnectorContainer.Count(); a++)
+ {
+ if(pConnObj == ((ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a))->pOrig)
+ return ((ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a))->pClone;
+ }
+ return 0L;
+}
+
+// #90129# restrict movement to WorkArea
+void ImpCheckInsertPos(Point& rPos, const Size& rSize, const Rectangle& rWorkArea)
+{
+ if(!rWorkArea.IsEmpty())
+ {
+ Rectangle aMarkRect(Point(rPos.X() - (rSize.Width() / 2), rPos.Y() - (rSize.Height() / 2)), rSize);
+
+ if(!aMarkRect.IsInside(rWorkArea))
+ {
+ if(aMarkRect.Left() < rWorkArea.Left())
+ {
+ rPos.X() += rWorkArea.Left() - aMarkRect.Left();
+ }
+
+ if(aMarkRect.Right() > rWorkArea.Right())
+ {
+ rPos.X() -= aMarkRect.Right() - rWorkArea.Right();
+ }
+
+ if(aMarkRect.Top() < rWorkArea.Top())
+ {
+ rPos.Y() += rWorkArea.Top() - aMarkRect.Top();
+ }
+
+ if(aMarkRect.Bottom() > rWorkArea.Bottom())
+ {
+ rPos.Y() -= aMarkRect.Bottom() - rWorkArea.Bottom();
+ }
+ }
+ }
+}
+
+bool View::InsertMetaFile( TransferableDataHelper& rDataHelper, const Point& rPos, ImageMap* pImageMap, bool bOptimize )
+{
+ GDIMetaFile aMtf;
+
+ if( !rDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMtf ) )
+ return false;
+
+/*
+SvFileStream aSvOutputStream( String( RTL_CONSTASCII_USTRINGPARAM( "/tmp/test.png" ) ), STREAM_WRITE | STREAM_TRUNC );
+Graphic aMtfGraphic( aMtf );
+Size aPreviewSizePixel( OutputDevice::LogicToLogic( aMtf.GetPrefSize(), aMtf.GetPrefMapMode(), MAP_PIXEL ) );
+
+if( aPreviewSizePixel.Width() && aPreviewSizePixel.Height() )
+{
+ const double fWH = static_cast< double >( aPreviewSizePixel.Width() ) / static_cast< double >( aPreviewSizePixel.Height() );
+
+ if( fWH <= 1.0 )
+ aPreviewSizePixel.Width() = static_cast< long >( 128.0 * fWH ), aPreviewSizePixel.Height() = 128;
+ else
+ aPreviewSizePixel.Width() = 128, aPreviewSizePixel.Height() = static_cast< long >( 128.0 / fWH );
+
+ if( GraphicConverter::Export( aSvOutputStream, aMtfGraphic.GetBitmapEx( &aPreviewSizePixel ), CVT_PNG ) )
+ {
+ // handle errror case here
+ }
+ else
+ {
+ // Success
+ }
+}
+*/
+ bool bVector = false;
+ Graphic aGraphic;
+
+ // check if metafile only contains a pixel image, if so insert a bitmap instead
+ if( bOptimize )
+ {
+ MetaAction* pAction = aMtf.FirstAction();
+ while( pAction && !bVector )
+ {
+ switch( pAction->GetType() )
+ {
+ case META_POINT_ACTION:
+ case META_LINE_ACTION:
+ case META_RECT_ACTION:
+ case META_ROUNDRECT_ACTION:
+ case META_ELLIPSE_ACTION:
+ case META_ARC_ACTION:
+ case META_PIE_ACTION:
+ case META_CHORD_ACTION:
+ case META_POLYLINE_ACTION:
+ case META_POLYGON_ACTION:
+ case META_POLYPOLYGON_ACTION:
+ case META_TEXT_ACTION:
+ case META_TEXTARRAY_ACTION:
+ case META_STRETCHTEXT_ACTION:
+ case META_TEXTRECT_ACTION:
+ case META_GRADIENT_ACTION:
+ case META_HATCH_ACTION:
+ case META_WALLPAPER_ACTION:
+ case META_EPS_ACTION:
+ case META_TEXTLINE_ACTION:
+ case META_FLOATTRANSPARENT_ACTION:
+ case META_GRADIENTEX_ACTION:
+ case META_BMPSCALEPART_ACTION:
+ case META_BMPEXSCALEPART_ACTION:
+ bVector = true;
+ break;
+ case META_BMP_ACTION:
+ case META_BMPSCALE_ACTION:
+ case META_BMPEX_ACTION:
+ case META_BMPEXSCALE_ACTION:
+ if( aGraphic.GetType() != GRAPHIC_NONE )
+ {
+ bVector = true;
+ }
+ else switch( pAction->GetType() )
+ {
+ case META_BMP_ACTION:
+ {
+ MetaBmpAction* pBmpAction = dynamic_cast< MetaBmpAction* >( pAction );
+ if( pBmpAction )
+ aGraphic = Graphic( pBmpAction->GetBitmap() );
+ }
+ break;
+ case META_BMPSCALE_ACTION:
+ {
+ MetaBmpScaleAction* pBmpScaleAction = dynamic_cast< MetaBmpScaleAction* >( pAction );
+ if( pBmpScaleAction )
+ aGraphic = Graphic( pBmpScaleAction->GetBitmap() );
+ }
+ break;
+ case META_BMPEX_ACTION:
+ {
+ MetaBmpExAction* pBmpExAction = dynamic_cast< MetaBmpExAction* >( pAction );
+ if( pBmpExAction )
+ aGraphic = Graphic( pBmpExAction->GetBitmapEx() );
+ }
+ break;
+ case META_BMPEXSCALE_ACTION:
+ {
+ MetaBmpExScaleAction* pBmpExScaleAction = dynamic_cast< MetaBmpExScaleAction* >( pAction );
+ if( pBmpExScaleAction )
+ aGraphic = Graphic( pBmpExScaleAction->GetBitmapEx() );
+ }
+ break;
+ }
+ }
+
+ pAction = aMtf.NextAction();
+ }
+ }
+
+ // it is not a vector metafile but it also has no graphic?
+ if( !bVector && (aGraphic.GetType() == GRAPHIC_NONE) )
+ bVector = true;
+
+ // #90129# restrict movement to WorkArea
+ Point aInsertPos( rPos );
+ Size aImageSize;
+ aImageSize = bVector ? aMtf.GetPrefSize() : aGraphic.GetSizePixel();
+ ImpCheckInsertPos(aInsertPos, aImageSize, GetWorkArea());
+
+ if( bVector )
+ aGraphic = Graphic( aMtf );
+
+ aGraphic.SetPrefMapMode( aMtf.GetPrefMapMode() );
+ aGraphic.SetPrefSize( aMtf.GetPrefSize() );
+ InsertGraphic( aGraphic, mnAction, aInsertPos, NULL, pImageMap );
+
+ return true;
+}
+
+sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper,
+ const Point& rPos, sal_Int8& rDnDAction, sal_Bool bDrag,
+ sal_uLong nFormat, sal_uInt16 nPage, sal_uInt16 nLayer )
+{
+ maDropPos = rPos;
+ mnAction = rDnDAction;
+ mbIsDropAllowed = sal_False;
+
+ TransferableDataHelper aDataHelper( rDataHelper );
+ SdrObject* pPickObj = NULL;
+ SdPage* pPage = NULL;
+ ImageMap* pImageMap = NULL;
+ sal_Bool bReturn = sal_False;
+ sal_Bool bLink = ( ( mnAction & DND_ACTION_LINK ) != 0 );
+ sal_Bool bCopy = ( ( ( mnAction & DND_ACTION_COPY ) != 0 ) || bLink );
+ sal_uLong nPasteOptions = SDRINSERT_SETDEFLAYER;
+
+ if (mpViewSh != NULL)
+ {
+ OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
+ SfxInPlaceClient* pIpClient = mpViewSh->GetViewShell()->GetIPClient();
+ if( mpViewSh->ISA(::sd::slidesorter::SlideSorterViewShell)
+ || (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive()))
+ nPasteOptions |= SDRINSERT_DONTMARK;
+ }
+
+ if( bDrag )
+ {
+ SdrPageView* pPV = NULL;
+ PickObj( rPos, getHitTolLog(), pPickObj, pPV );
+ }
+
+ if( nPage != SDRPAGE_NOTFOUND )
+ pPage = (SdPage*) mpDoc->GetPage( nPage );
+
+ SdTransferable* pOwnData = NULL;
+ SdTransferable* pImplementation = SdTransferable::getImplementation( aDataHelper.GetTransferable() );
+
+ // try to get own transfer data
+ if( pImplementation )
+ {
+ if( SD_MOD()->pTransferClip == (SdTransferable*) pImplementation )
+ pOwnData = SD_MOD()->pTransferClip;
+ else if( SD_MOD()->pTransferDrag == (SdTransferable*) pImplementation )
+ pOwnData = SD_MOD()->pTransferDrag;
+ else if( SD_MOD()->pTransferSelection == (SdTransferable*) pImplementation )
+ pOwnData = SD_MOD()->pTransferSelection;
+ }
+
+ // ImageMap?
+ if( !pOwnData && aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVIM ) )
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVIM, xStm ) )
+ {
+ pImageMap = new ImageMap;
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ pImageMap->Read( *xStm, String() );
+ }
+ }
+
+ bool bTable = false;
+ // check special cases for pasting table formats as RTL
+ if( !bLink && (!nFormat || (nFormat == SOT_FORMAT_RTF)) )
+ {
+ // if the objekt supports rtf and there is a table involved, default is to create a table
+ if( aDataHelper.HasFormat( SOT_FORMAT_RTF ) && ! aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING ) )
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( FORMAT_RTF, xStm ) )
+ {
+ xStm->Seek( 0 );
+
+ ByteString aLine;
+ while( xStm->ReadLine(aLine) )
+ {
+ xub_StrLen x = aLine.Search( "\\trowd" );
+ if( x != STRING_NOTFOUND )
+ {
+ bTable = true;
+ nFormat = FORMAT_RTF;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if( pOwnData && !nFormat )
+ {
+ const View* pSourceView = pOwnData->GetView();
+
+
+ if( pOwnData->GetDocShell() && pOwnData->IsPageTransferable() && ISA( View ) )
+ {
+ mpClipboard->HandlePageDrop (*pOwnData);
+ }
+ else if( pSourceView )
+ {
+ if( pSourceView == this )
+ {
+ // same view
+ if( nLayer != SDRLAYER_NOTFOUND )
+ {
+ // drop on layer tab bar
+ SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
+ SdrLayer* pLayer = rLayerAdmin.GetLayerPerID( nLayer );
+ SdrPageView* pPV = GetSdrPageView();
+ String aLayer( pLayer->GetName() );
+
+ if( !pPV->IsLayerLocked( aLayer ) )
+ {
+ pOwnData->SetInternalMove( sal_True );
+ SortMarkedObjects();
+
+ for( sal_uLong nM = 0; nM < GetMarkedObjectCount(); nM++ )
+ {
+ SdrMark* pM = GetSdrMarkByIndex( nM );
+ SdrObject* pO = pM->GetMarkedSdrObj();
+
+ if( pO )
+ {
+ // #i11702#
+ if( IsUndoEnabled() )
+ {
+ BegUndo(String(SdResId(STR_MODIFYLAYER)));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoObjectLayerChange(*pO, pO->GetLayer(), (SdrLayerID)nLayer));
+ EndUndo();
+ }
+
+ pO->SetLayer( (SdrLayerID) nLayer );
+ }
+ }
+
+ bReturn = sal_True;
+ }
+ }
+ else
+ {
+ SdrPageView* pPV = GetSdrPageView();
+ sal_Bool bDropOnTabBar = sal_True;
+
+ if( !pPage && pPV->GetPage()->GetPageNum() != mnDragSrcPgNum )
+ {
+ pPage = (SdPage*) pPV->GetPage();
+ bDropOnTabBar = sal_False;
+ }
+
+ if( pPage )
+ {
+ // drop on other page
+ String aActiveLayer( GetActiveLayer() );
+
+ if( !pPV->IsLayerLocked( aActiveLayer ) )
+ {
+ if( !IsPresObjSelected() )
+ {
+ SdrMarkList* pMarkList;
+
+ if( (mnDragSrcPgNum != SDRPAGE_NOTFOUND) && (mnDragSrcPgNum != pPV->GetPage()->GetPageNum()) )
+ {
+ pMarkList = mpDragSrcMarkList;
+ }
+ else
+ {
+ // actual mark list is used
+ pMarkList = new SdrMarkList( GetMarkedObjectList());
+ }
+
+ pMarkList->ForceSort();
+
+ // #83525# stuff to remember originals and clones
+ Container aConnectorContainer(0);
+ sal_uInt32 a, nConnectorCount(0L);
+ Point aCurPos;
+
+ // calculate real position of current
+ // source objects, if necessary (#103207)
+ if( pOwnData == SD_MOD()->pTransferSelection )
+ {
+ Rectangle aCurBoundRect;
+
+ if( pMarkList->TakeBoundRect( pPV, aCurBoundRect ) )
+ aCurPos = aCurBoundRect.TopLeft();
+ else
+ aCurPos = pOwnData->GetStartPos();
+ }
+ else
+ aCurPos = pOwnData->GetStartPos();
+
+ const Size aVector( maDropPos.X() - aCurPos.X(), maDropPos.Y() - aCurPos.Y() );
+
+ for(a = 0; a < pMarkList->GetMarkCount(); a++)
+ {
+ SdrMark* pM = pMarkList->GetMark(a);
+ SdrObject* pObj = pM->GetMarkedSdrObj()->Clone();
+
+ if(pObj)
+ {
+ if(!bDropOnTabBar)
+ {
+ // #83525# do a NbcMove(...) instead of setting SnapRects here
+ pObj->NbcMove(aVector);
+ }
+
+ pPage->InsertObject(pObj);
+
+ if( IsUndoEnabled() )
+ {
+ BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
+ EndUndo();
+ }
+
+ // #83525#
+ ImpRememberOrigAndClone* pRem = new ImpRememberOrigAndClone;
+ pRem->pOrig = pM->GetMarkedSdrObj();
+ pRem->pClone = pObj;
+ aConnectorContainer.Insert(pRem, CONTAINER_APPEND);
+
+ if(pObj->ISA(SdrEdgeObj))
+ nConnectorCount++;
+ }
+ }
+
+ // #83525# try to re-establish connections at clones
+ if(nConnectorCount)
+ {
+ for(a = 0; a < aConnectorContainer.Count(); a++)
+ {
+ ImpRememberOrigAndClone* pRem = (ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a);
+
+ if(pRem->pClone->ISA(SdrEdgeObj))
+ {
+ SdrEdgeObj* pOrigEdge = (SdrEdgeObj*)pRem->pOrig;
+ SdrEdgeObj* pCloneEdge = (SdrEdgeObj*)pRem->pClone;
+
+ // test first connection
+ SdrObjConnection& rConn0 = pOrigEdge->GetConnection(sal_False);
+ SdrObject* pConnObj = rConn0.GetObject();
+ if(pConnObj)
+ {
+ SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
+ if(pConnClone)
+ {
+ // if dest obj was cloned, too, re-establish connection
+ pCloneEdge->ConnectToNode(sal_False, pConnClone);
+ pCloneEdge->GetConnection(sal_False).SetConnectorId(rConn0.GetConnectorId());
+ }
+ else
+ {
+ // set position of connection point of original connected object
+ const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
+ if(pGlueList)
+ {
+ sal_uInt16 nInd = pGlueList->FindGluePoint(rConn0.GetConnectorId());
+
+ if(SDRGLUEPOINT_NOTFOUND != nInd)
+ {
+ const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
+ Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
+ aPosition.X() += aVector.A();
+ aPosition.Y() += aVector.B();
+ pCloneEdge->SetTailPoint(sal_False, aPosition);
+ }
+ }
+ }
+ }
+
+ // test second connection
+ SdrObjConnection& rConn1 = pOrigEdge->GetConnection(sal_True);
+ pConnObj = rConn1.GetObject();
+ if(pConnObj)
+ {
+ SdrObject* pConnClone = ImpGetClone(aConnectorContainer, pConnObj);
+ if(pConnClone)
+ {
+ // if dest obj was cloned, too, re-establish connection
+ pCloneEdge->ConnectToNode(sal_True, pConnClone);
+ pCloneEdge->GetConnection(sal_True).SetConnectorId(rConn1.GetConnectorId());
+ }
+ else
+ {
+ // set position of connection point of original connected object
+ const SdrGluePointList* pGlueList = pConnObj->GetGluePointList();
+ if(pGlueList)
+ {
+ sal_uInt16 nInd = pGlueList->FindGluePoint(rConn1.GetConnectorId());
+
+ if(SDRGLUEPOINT_NOTFOUND != nInd)
+ {
+ const SdrGluePoint& rGluePoint = (*pGlueList)[nInd];
+ Point aPosition = rGluePoint.GetAbsolutePos(*pConnObj);
+ aPosition.X() += aVector.A();
+ aPosition.Y() += aVector.B();
+ pCloneEdge->SetTailPoint(sal_True, aPosition);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // #83525# cleanup remember classes
+ for(a = 0; a < aConnectorContainer.Count(); a++)
+ delete (ImpRememberOrigAndClone*)aConnectorContainer.GetObject(a);
+
+ if( pMarkList != mpDragSrcMarkList )
+ delete pMarkList;
+
+ bReturn = sal_True;
+ }
+ else
+ {
+ maDropErrorTimer.Start();
+ bReturn = sal_False;
+ }
+ }
+ }
+ else
+ {
+ pOwnData->SetInternalMove( sal_True );
+ MoveAllMarked( Size( maDropPos.X() - pOwnData->GetStartPos().X(),
+ maDropPos.Y() - pOwnData->GetStartPos().Y() ), bCopy );
+ bReturn = sal_True;
+ }
+ }
+ }
+ else
+ {
+ // different views
+ if( !pSourceView->IsPresObjSelected() )
+ {
+ // model is owned by from AllocModel() created DocShell
+ SdDrawDocument* pSourceDoc = (SdDrawDocument*) pSourceView->GetModel();
+ pSourceDoc->CreatingDataObj( pOwnData );
+ SdDrawDocument* pModel = (SdDrawDocument*) pSourceView->GetAllMarkedModel();
+ bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
+
+ if( !pPage )
+ pPage = (SdPage*) GetSdrPageView()->GetPage();
+
+ String aLayout( pPage->GetLayoutName() );
+ aLayout.Erase( aLayout.SearchAscii( SD_LT_SEPARATOR ) );
+ pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
+ pSourceDoc->CreatingDataObj( NULL );
+ }
+ else
+ {
+ maDropErrorTimer.Start();
+ bReturn = sal_False;
+ }
+ }
+ }
+ else
+ {
+ SdDrawDocument* pWorkModel = (SdDrawDocument*) pOwnData->GetWorkDocument();
+ SdPage* pWorkPage = (SdPage*) pWorkModel->GetSdPage( 0, PK_STANDARD );
+
+ pWorkPage->SetRectsDirty();
+
+ // #104148# Use SnapRect, not BoundRect
+ Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() );
+
+ maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
+ maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
+
+ // delete pages, that are not of any interest for us
+ for( long i = ( pWorkModel->GetPageCount() - 1 ); i >= 0; i-- )
+ {
+ SdPage* pP = static_cast< SdPage* >( pWorkModel->GetPage( (sal_uInt16) i ) );
+
+ if( pP->GetPageKind() != PK_STANDARD )
+ pWorkModel->DeletePage( (sal_uInt16) i );
+ }
+
+ bReturn = Paste( *pWorkModel, maDropPos, pPage, nPasteOptions );
+
+ if( !pPage )
+ pPage = (SdPage*) GetSdrPageView()->GetPage();
+
+ String aLayout(pPage->GetLayoutName());
+ aLayout.Erase(aLayout.SearchAscii(SD_LT_SEPARATOR));
+ pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
+ }
+ }
+ else if( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_DRAWING ) )
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm ) )
+ {
+ sal_Bool bChanged = sal_False;
+
+ DrawDocShellRef xShell = new DrawDocShell(SFX_CREATE_MODE_INTERNAL);
+ xShell->DoInitNew(0);
+
+ SdDrawDocument* pModel = xShell->GetDoc();
+ pModel->InsertPage(pModel->AllocPage(false));
+
+ Reference< XComponent > xComponent( xShell->GetModel(), UNO_QUERY );
+ xStm->Seek( 0 );
+
+ com::sun::star::uno::Reference< com::sun::star::io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) );
+ bReturn = SvxDrawingLayerImport( pModel, xInputStream, xComponent, "com.sun.star.comp.Impress.XMLOasisImporter" );
+
+ if( pModel->GetPageCount() == 0 )
+ {
+ DBG_ERROR("empty or invalid drawing xml document on clipboard!" );
+ }
+ else
+ {
+ if( bReturn )
+ {
+ if( pModel->GetSdPage( 0, PK_STANDARD )->GetObjCount() == 1 )
+ {
+ // only one object
+ SdrObject* pObj = pModel->GetSdPage( 0, PK_STANDARD )->GetObj( 0 );
+ SdrObject* pPickObj2 = NULL;
+ SdrPageView* pPV = NULL;
+ PickObj( rPos, getHitTolLog(), pPickObj2, pPV );
+
+ if( ( mnAction & DND_ACTION_MOVE ) && pPickObj2 && pObj )
+ {
+ // replace object
+ SdrObject* pNewObj = pObj->Clone();
+ Rectangle aPickObjRect( pPickObj2->GetCurrentBoundRect() );
+ Size aPickObjSize( aPickObjRect.GetSize() );
+ Point aVec( aPickObjRect.TopLeft() );
+ Rectangle aObjRect( pNewObj->GetCurrentBoundRect() );
+ Size aObjSize( aObjRect.GetSize() );
+
+ Fraction aScaleWidth( aPickObjSize.Width(), aObjSize.Width() );
+ Fraction aScaleHeight( aPickObjSize.Height(), aObjSize.Height() );
+ pNewObj->NbcResize( aObjRect.TopLeft(), aScaleWidth, aScaleHeight );
+
+ aVec -= aObjRect.TopLeft();
+ pNewObj->NbcMove( Size( aVec.X(), aVec.Y() ) );
+
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo( String( SdResId(STR_UNDO_DRAGDROP ) ) );
+ pNewObj->NbcSetLayer( pPickObj->GetLayer() );
+ SdrPage* pWorkPage = GetSdrPageView()->GetPage();
+ pWorkPage->InsertObject( pNewObj );
+ if( bUndo )
+ {
+ AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoNewObject( *pNewObj ) );
+ AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject( *pPickObj2 ) );
+ }
+ pWorkPage->RemoveObject( pPickObj2->GetOrdNum() );
+
+ if( bUndo )
+ {
+ EndUndo();
+ }
+ else
+ {
+ SdrObject::Free(pPickObj2 );
+ }
+ bChanged = sal_True;
+ mnAction = DND_ACTION_COPY;
+ }
+ else if( ( mnAction & DND_ACTION_LINK ) && pPickObj && pObj && !pPickObj->ISA( SdrGrafObj ) && !pPickObj->ISA( SdrOle2Obj ) )
+ {
+ SfxItemSet aSet( mpDoc->GetPool() );
+
+ // set new attributes to object
+ const bool bUndo = IsUndoEnabled();
+ if( bUndo )
+ {
+ BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
+ AddUndo( mpDoc->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
+ }
+ aSet.Put( pObj->GetMergedItemSet() );
+
+ // Eckenradius soll nicht uebernommen werden.
+ // In der Gallery stehen Farbverlauefe (Rechtecke)
+ // welche den Eckenradius == 0 haben. Dieser soll
+ // nicht auf das Objekt uebertragen werden.
+ aSet.ClearItem( SDRATTR_ECKENRADIUS );
+
+ pPickObj->SetMergedItemSetAndBroadcast( aSet );
+
+ if( pPickObj->ISA( E3dObject ) && pObj->ISA( E3dObject ) )
+ {
+ // Zusaetzlich 3D Attribute handeln
+ SfxItemSet aNewSet( mpDoc->GetPool(), SID_ATTR_3D_START, SID_ATTR_3D_END, 0 );
+ SfxItemSet aOldSet( mpDoc->GetPool(), SID_ATTR_3D_START, SID_ATTR_3D_END, 0 );
+
+ aOldSet.Put(pPickObj->GetMergedItemSet());
+ aNewSet.Put( pObj->GetMergedItemSet() );
+
+ if( bUndo )
+ AddUndo( new E3dAttributesUndoAction( *mpDoc, this, (E3dObject*) pPickObj, aNewSet, aOldSet, sal_False ) );
+ pPickObj->SetMergedItemSetAndBroadcast( aNewSet );
+ }
+
+ if( bUndo )
+ EndUndo();
+ bChanged = sal_True;
+ }
+ }
+ }
+
+ if( !bChanged )
+ {
+ SdrPage* pWorkPage = pModel->GetSdPage( 0, PK_STANDARD );
+
+ pWorkPage->SetRectsDirty();
+
+ if( pOwnData )
+ {
+ // #104148# Use SnapRect, not BoundRect
+ Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() );
+
+ maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
+ maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
+ }
+
+ bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
+ }
+
+ xShell->DoClose();
+ }
+ }
+ }
+ else if( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE ) )
+ {
+ ::rtl::OUString aOUString;
+
+ if( aDataHelper.GetString( SOT_FORMATSTR_ID_SBA_FIELDDATAEXCHANGE, aOUString ) )
+ {
+ SdrObject* pObj = CreateFieldControl( aOUString );
+
+ if( pObj )
+ {
+ Rectangle aRect( pObj->GetLogicRect() );
+ Size aSize( aRect.GetSize() );
+
+ maDropPos.X() -= ( aSize.Width() >> 1 );
+ maDropPos.Y() -= ( aSize.Height() >> 1 );
+
+ aRect.SetPos( maDropPos );
+ pObj->SetLogicRect( aRect );
+ InsertObjectAtView( pObj, *GetSdrPageView(), SDRINSERT_SETDEFLAYER );
+ bReturn = sal_True;
+ }
+ }
+ }
+ else if( !bLink &&
+ ( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBED_SOURCE ) ||
+ CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBEDDED_OBJ ) ) &&
+ aDataHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) )
+ {
+ //TODO/LATER: is it possible that this format is binary?! (from old versions of SO)
+ uno::Reference < io::XInputStream > xStm;
+ TransferableObjectDescriptor aObjDesc;
+
+ if( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR, aObjDesc ) &&
+ ( aDataHelper.GetInputStream( nFormat ? nFormat : SOT_FORMATSTR_ID_EMBED_SOURCE, xStm ) ||
+ aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ, xStm ) ) )
+ {
+ if( mpDoc->GetDocSh() && ( mpDoc->GetDocSh()->GetClassName() == aObjDesc.maClassName ) )
+ {
+ uno::Reference < embed::XStorage > xStore( ::comphelper::OStorageHelper::GetStorageFromInputStream( xStm ) );
+ ::sd::DrawDocShellRef xDocShRef( new ::sd::DrawDocShell( SFX_CREATE_MODE_EMBEDDED, sal_True, mpDoc->GetDocumentType() ) );
+
+ // mba: BaseURL doesn't make sense for clipboard functionality
+ SfxMedium *pMedium = new SfxMedium( xStore, String() );
+ if( xDocShRef->DoLoad( pMedium ) )
+ {
+ SdDrawDocument* pModel = (SdDrawDocument*) xDocShRef->GetDoc();
+ SdPage* pWorkPage = (SdPage*) pModel->GetSdPage( 0, PK_STANDARD );
+
+ pWorkPage->SetRectsDirty();
+
+ if( pOwnData )
+ {
+ // #104148# Use SnapRect, not BoundRect
+ Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() );
+
+ maDropPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
+ maDropPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
+ }
+
+ // delete pages, that are not of any interest for us
+ for( long i = ( pModel->GetPageCount() - 1 ); i >= 0; i-- )
+ {
+ SdPage* pP = static_cast< SdPage* >( pModel->GetPage( (sal_uInt16) i ) );
+
+ if( pP->GetPageKind() != PK_STANDARD )
+ pModel->DeletePage( (sal_uInt16) i );
+ }
+
+ bReturn = Paste( *pModel, maDropPos, pPage, nPasteOptions );
+
+ if( !pPage )
+ pPage = (SdPage*) GetSdrPageView()->GetPage();
+
+ String aLayout(pPage->GetLayoutName());
+ aLayout.Erase(aLayout.SearchAscii(SD_LT_SEPARATOR));
+ pPage->SetPresentationLayout( aLayout, sal_False, sal_False );
+ }
+
+ xDocShRef->DoClose();
+ xDocShRef.Clear();
+
+ }
+ else
+ {
+ ::rtl::OUString aName;
+ uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
+ if ( xObj.is() )
+ {
+ svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
+
+ // try to get the replacement image from the clipboard
+ Graphic aGraphic;
+ sal_uLong nGrFormat = 0;
+
+// (wg. Selection Manager bei Trustet Solaris)
+#ifndef SOLARIS
+/*
+ if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
+ nGrFormat = SOT_FORMATSTR_ID_SVXB;
+ else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
+ nGrFormat = SOT_FORMAT_GDIMETAFILE;
+ else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
+ nGrFormat = SOT_FORMAT_BITMAP;
+*/
+#endif
+
+ // insert replacement image ( if there is one ) into the object helper
+ if ( nGrFormat )
+ {
+ datatransfer::DataFlavor aDataFlavor;
+ SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
+ aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
+ }
+
+ Size aSize;
+ if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
+ {
+ if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
+ aSize = aObjDesc.maSize;
+ else
+ {
+ MapMode aMapMode( MAP_100TH_MM );
+ aSize = aObjRef.GetSize( &aMapMode );
+ }
+ }
+ else
+ {
+ awt::Size aSz;
+ MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
+ if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
+ {
+ Size aTmp( OutputDevice::LogicToLogic( aObjDesc.maSize, MAP_100TH_MM, aMapUnit ) );
+ aSz.Width = aTmp.Width();
+ aSz.Height = aTmp.Height();
+ xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
+ }
+
+ try
+ {
+ aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ // if the size still was not set the default size will be set later
+ }
+
+ aSize = Size( aSz.Width, aSz.Height );
+
+ if( !aSize.Width() || !aSize.Height() )
+ {
+ aSize.Width() = 14100;
+ aSize.Height() = 10000;
+ aSize = OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM, aMapUnit );
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
+ }
+
+ aSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
+ }
+
+ Size aMaxSize( mpDoc->GetMaxObjSize() );
+
+ maDropPos.X() -= Min( aSize.Width(), aMaxSize.Width() ) >> 1;
+ maDropPos.Y() -= Min( aSize.Height(), aMaxSize.Height() ) >> 1;
+
+ Rectangle aRect( maDropPos, aSize );
+ SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect );
+ SdrPageView* pPV = GetSdrPageView();
+ sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
+
+ if (mpViewSh!=NULL)
+ {
+ OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
+ SfxInPlaceClient* pIpClient
+ = mpViewSh->GetViewShell()->GetIPClient();
+ if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
+ nOptions |= SDRINSERT_DONTMARK;
+ }
+
+ InsertObjectAtView( pObj, *pPV, nOptions );
+
+ if( pImageMap )
+ pObj->InsertUserData( new SdIMapInfo( *pImageMap ) );
+
+ if ( pObj && pObj->IsChart() )
+ {
+ bool bDisableDataTableDialog = false;
+ svt::EmbeddedObjectRef::TryRunningState( xObj );
+ uno::Reference< beans::XPropertySet > xProps( xObj->getComponent(), uno::UNO_QUERY );
+ if ( xProps.is() &&
+ ( xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ) ) >>= bDisableDataTableDialog ) &&
+ bDisableDataTableDialog )
+ {
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableDataTableDialog" ) ),
+ uno::makeAny( sal_False ) );
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableComplexChartTypes" ) ),
+ uno::makeAny( sal_False ) );
+ uno::Reference< util::XModifiable > xModifiable( xProps, uno::UNO_QUERY );
+ if ( xModifiable.is() )
+ {
+ xModifiable->setModified( sal_True );
+ }
+ }
+ }
+
+ bReturn = sal_True;
+ }
+ }
+ }
+ }
+ else if( !bLink &&
+ ( CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE ) ||
+ CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EMBED_SOURCE_OLE ) ) &&
+ aDataHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE ) )
+ {
+ // online insert ole if format is forced or no gdi metafile is available
+ if( (nFormat != 0) || !aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
+ {
+ uno::Reference < io::XInputStream > xStm;
+ TransferableObjectDescriptor aObjDesc;
+
+ if ( aDataHelper.GetTransferableObjectDescriptor( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR_OLE, aObjDesc ) )
+ {
+ uno::Reference < embed::XEmbeddedObject > xObj;
+ ::rtl::OUString aName;
+
+ if ( aDataHelper.GetInputStream( nFormat ? nFormat : SOT_FORMATSTR_ID_EMBED_SOURCE_OLE, xStm ) ||
+ aDataHelper.GetInputStream( SOT_FORMATSTR_ID_EMBEDDED_OBJ_OLE, xStm ) )
+ {
+ xObj = mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xStm, aName );
+ }
+ else
+ {
+ try
+ {
+ uno::Reference< embed::XStorage > xTmpStor = ::comphelper::OStorageHelper::GetTemporaryStorage();
+ uno::Reference < embed::XEmbedObjectClipboardCreator > xClipboardCreator(
+ ::comphelper::getProcessServiceFactory()->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.embed.MSOLEObjectSystemCreator")) ),
+ uno::UNO_QUERY_THROW );
+
+ embed::InsertedObjectInfo aInfo = xClipboardCreator->createInstanceInitFromClipboard(
+ xTmpStor,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "DummyName" ) ),
+ uno::Sequence< beans::PropertyValue >() );
+
+ // TODO/LATER: in future InsertedObjectInfo will be used to get container related information
+ // for example whether the object should be an iconified one
+ xObj = aInfo.Object;
+ if ( xObj.is() )
+ mpDocSh->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
+ }
+ catch( uno::Exception& )
+ {}
+ }
+
+ if ( xObj.is() )
+ {
+ svt::EmbeddedObjectRef aObjRef( xObj, aObjDesc.mnViewAspect );
+
+ // try to get the replacement image from the clipboard
+ Graphic aGraphic;
+ sal_uLong nGrFormat = 0;
+
+// (wg. Selection Manager bei Trustet Solaris)
+#ifndef SOLARIS
+ if( aDataHelper.GetGraphic( SOT_FORMATSTR_ID_SVXB, aGraphic ) )
+ nGrFormat = SOT_FORMATSTR_ID_SVXB;
+ else if( aDataHelper.GetGraphic( FORMAT_GDIMETAFILE, aGraphic ) )
+ nGrFormat = SOT_FORMAT_GDIMETAFILE;
+ else if( aDataHelper.GetGraphic( FORMAT_BITMAP, aGraphic ) )
+ nGrFormat = SOT_FORMAT_BITMAP;
+#endif
+
+ // insert replacement image ( if there is one ) into the object helper
+ if ( nGrFormat )
+ {
+ datatransfer::DataFlavor aDataFlavor;
+ SotExchange::GetFormatDataFlavor( nGrFormat, aDataFlavor );
+ aObjRef.SetGraphic( aGraphic, aDataFlavor.MimeType );
+ }
+
+ Size aSize;
+ if ( aObjDesc.mnViewAspect == embed::Aspects::MSOLE_ICON )
+ {
+ if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
+ aSize = aObjDesc.maSize;
+ else
+ {
+ MapMode aMapMode( MAP_100TH_MM );
+ aSize = aObjRef.GetSize( &aMapMode );
+ }
+ }
+ else
+ {
+ MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( aObjDesc.mnViewAspect ) );
+
+ awt::Size aSz;
+ try{
+ aSz = xObj->getVisualAreaSize( aObjDesc.mnViewAspect );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ // the default size will be set later
+ }
+
+ if( aObjDesc.maSize.Width() && aObjDesc.maSize.Height() )
+ {
+ Size aTmp( OutputDevice::LogicToLogic( aObjDesc.maSize, MAP_100TH_MM, aMapUnit ) );
+ if ( aSz.Width != aTmp.Width() || aSz.Height != aTmp.Height() )
+ {
+ aSz.Width = aTmp.Width();
+ aSz.Height = aTmp.Height();
+ xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
+ }
+ }
+
+ aSize = Size( aSz.Width, aSz.Height );
+
+ if( !aSize.Width() || !aSize.Height() )
+ {
+ aSize = OutputDevice::LogicToLogic( Size(14100, 10000), MAP_100TH_MM, aMapUnit );
+ aSz.Width = aSize.Width();
+ aSz.Height = aSize.Height();
+ xObj->setVisualAreaSize( aObjDesc.mnViewAspect, aSz );
+ }
+
+ aSize = OutputDevice::LogicToLogic( aSize, aMapUnit, MAP_100TH_MM );
+ }
+
+ Size aMaxSize( mpDoc->GetMaxObjSize() );
+
+ maDropPos.X() -= Min( aSize.Width(), aMaxSize.Width() ) >> 1;
+ maDropPos.Y() -= Min( aSize.Height(), aMaxSize.Height() ) >> 1;
+
+ Rectangle aRect( maDropPos, aSize );
+ SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect );
+ SdrPageView* pPV = GetSdrPageView();
+ sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
+
+ if (mpViewSh!=NULL)
+ {
+ OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
+ SfxInPlaceClient* pIpClient
+ = mpViewSh->GetViewShell()->GetIPClient();
+ if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
+ nOptions |= SDRINSERT_DONTMARK;
+ }
+
+ InsertObjectAtView( pObj, *pPV, nOptions );
+
+ if( pImageMap )
+ pObj->InsertUserData( new SdIMapInfo( *pImageMap ) );
+
+ // let the object stay in loaded state after insertion
+ pObj->Unload();
+ bReturn = sal_True;
+ }
+ }
+ }
+
+ if( !bReturn && aDataHelper.HasFormat( FORMAT_GDIMETAFILE ) )
+ {
+ // if no object was inserted, insert a picture
+ InsertMetaFile( aDataHelper, rPos, pImageMap, true );
+ }
+ }
+ else if( ( !bLink || pPickObj ) && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_SVXB ) )
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm ) )
+ {
+ Point aInsertPos( rPos );
+ Graphic aGraphic;
+
+ *xStm >> aGraphic;
+
+ if( pOwnData && pOwnData->GetWorkDocument() )
+ {
+ const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
+ SdrPage* pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
+ pWorkModel->GetSdPage( 0, PK_STANDARD ) :
+ pWorkModel->GetPage( 0 ) );
+
+ pWorkPage->SetRectsDirty();
+
+ // #104148# Use SnapRect, not BoundRect
+ Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() );
+
+ aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
+ aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
+ }
+
+ // #90129# restrict movement to WorkArea
+ Size aImageMapSize = OutputDevice::LogicToLogic(aGraphic.GetPrefSize(),
+ aGraphic.GetPrefMapMode(), MapMode(MAP_100TH_MM));
+
+ ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
+
+ InsertGraphic( aGraphic, mnAction, aInsertPos, NULL, pImageMap );
+ bReturn = sal_True;
+ }
+ }
+ else if( ( !bLink || pPickObj ) && CHECK_FORMAT_TRANS( FORMAT_GDIMETAFILE ) )
+ {
+ Point aInsertPos( rPos );
+
+ if( pOwnData && pOwnData->GetWorkDocument() )
+
+ {
+ const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
+ SdrPage* pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
+ pWorkModel->GetSdPage( 0, PK_STANDARD ) :
+ pWorkModel->GetPage( 0 ) );
+
+ pWorkPage->SetRectsDirty();
+
+ // #104148# Use SnapRect, not BoundRect
+ Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() );
+
+ aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
+ aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
+ }
+
+ bReturn = InsertMetaFile( aDataHelper, aInsertPos, pImageMap, nFormat == 0 ? true : false ) ? sal_True : sal_False;
+ }
+ else if( ( !bLink || pPickObj ) && CHECK_FORMAT_TRANS( FORMAT_BITMAP ) )
+ {
+ Bitmap aBmp;
+
+ if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp ) )
+ {
+ Point aInsertPos( rPos );
+
+ if( pOwnData && pOwnData->GetWorkDocument() )
+ {
+ const SdDrawDocument* pWorkModel = pOwnData->GetWorkDocument();
+ SdrPage* pWorkPage = (SdrPage*) ( ( pWorkModel->GetPageCount() > 1 ) ?
+ pWorkModel->GetSdPage( 0, PK_STANDARD ) :
+ pWorkModel->GetPage( 0 ) );
+
+ pWorkPage->SetRectsDirty();
+
+ // #104148# Use SnapRect, not BoundRect
+ Size aSize( pWorkPage->GetAllObjSnapRect().GetSize() );
+
+ aInsertPos.X() = pOwnData->GetStartPos().X() + ( aSize.Width() >> 1 );
+ aInsertPos.Y() = pOwnData->GetStartPos().Y() + ( aSize.Height() >> 1 );
+ }
+
+ // #90129# restrict movement to WorkArea
+ Size aImageMapSize(aBmp.GetPrefSize());
+ ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
+
+ InsertGraphic( aBmp, mnAction, aInsertPos, NULL, pImageMap );
+ bReturn = sal_True;
+ }
+ }
+ else if( pPickObj && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_XFA ) )
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_XFA, xStm ) )
+ {
+ XFillExchangeData aFillData( XFillAttrSetItem( &mpDoc->GetPool() ) );
+
+ *xStm >> aFillData;
+
+ if( IsUndoEnabled() )
+ {
+ BegUndo( String( SdResId( STR_UNDO_DRAGDROP ) ) );
+ AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pPickObj ) );
+ EndUndo();
+ }
+
+ XFillAttrSetItem* pSetItem = aFillData.GetXFillAttrSetItem();
+ SfxItemSet rSet = pSetItem->GetItemSet();
+ XFillStyle eFill= ( (XFillStyleItem&) rSet.Get( XATTR_FILLSTYLE ) ).GetValue();
+
+ if( eFill == XFILL_SOLID || eFill == XFILL_NONE )
+ {
+ const XFillColorItem& rColItem = (XFillColorItem&) rSet.Get( XATTR_FILLCOLOR );
+ Color aColor( rColItem.GetColorValue() );
+ String aName( rColItem.GetName() );
+ SfxItemSet aSet( mpDoc->GetPool() );
+ sal_Bool bClosed = pPickObj->IsClosedObj();
+ ::sd::Window* pWin = mpViewSh->GetActiveWindow();
+ sal_uInt16 nHitLog = (sal_uInt16) pWin->PixelToLogic(
+ Size(FuPoor::HITPIX, 0 ) ).Width();
+ const long n2HitLog = nHitLog << 1;
+ Point aHitPosR( rPos );
+ Point aHitPosL( rPos );
+ Point aHitPosT( rPos );
+ Point aHitPosB( rPos );
+ const SetOfByte* pVisiLayer = &GetSdrPageView()->GetVisibleLayers();
+
+ aHitPosR.X() += n2HitLog;
+ aHitPosL.X() -= n2HitLog;
+ aHitPosT.Y() += n2HitLog;
+ aHitPosB.Y() -= n2HitLog;
+
+ if( bClosed &&
+ SdrObjectPrimitiveHit(*pPickObj, aHitPosR, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
+ SdrObjectPrimitiveHit(*pPickObj, aHitPosL, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
+ SdrObjectPrimitiveHit(*pPickObj, aHitPosT, nHitLog, *GetSdrPageView(), pVisiLayer, false) &&
+ SdrObjectPrimitiveHit(*pPickObj, aHitPosB, nHitLog, *GetSdrPageView(), pVisiLayer, false) )
+ {
+ // area fill
+ if(eFill == XFILL_SOLID )
+ aSet.Put(XFillColorItem(aName, aColor));
+
+ aSet.Put( XFillStyleItem( eFill ) );
+ }
+ else
+ aSet.Put( XLineColorItem( aName, aColor ) );
+
+ // Textfarbe hinzufuegen
+ pPickObj->SetMergedItemSetAndBroadcast( aSet );
+ }
+ }
+ }
+ else if( !bLink && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_HTML ) )
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_HTML, xStm ) )
+ {
+ xStm->Seek( 0 );
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_HTML, maDropPos, pPage, nPasteOptions );
+ }
+ }
+ else if( !bLink && CHECK_FORMAT_TRANS( SOT_FORMATSTR_ID_EDITENGINE ) )
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_EDITENGINE, xStm ) )
+ {
+ OutlinerView* pOLV = GetTextEditOutlinerView();
+
+ xStm->Seek( 0 );
+
+ if( pOLV )
+ {
+ Rectangle aRect( pOLV->GetOutputArea() );
+ Point aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
+
+ if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
+ {
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ pOLV->Read( *xStm, String(), EE_FORMAT_BIN, sal_False, mpDocSh->GetHeaderAttributes() );
+ bReturn = sal_True;
+ }
+ }
+
+ if( !bReturn )
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_BIN, maDropPos, pPage, nPasteOptions );
+ }
+ }
+ else if( !bLink && CHECK_FORMAT_TRANS( FORMAT_RTF ) )
+ {
+ SotStorageStreamRef xStm;
+
+ if( aDataHelper.GetSotStorageStream( FORMAT_RTF, xStm ) )
+ {
+ xStm->Seek( 0 );
+
+ if( bTable )
+ {
+ bReturn = PasteRTFTable( xStm, pPage, nPasteOptions );
+ }
+ else
+ {
+ OutlinerView* pOLV = GetTextEditOutlinerView();
+
+ if( pOLV )
+ {
+ Rectangle aRect( pOLV->GetOutputArea() );
+ Point aPos( pOLV->GetWindow()->PixelToLogic( maDropPos ) );
+
+ if( aRect.IsInside( aPos ) || ( !bDrag && IsTextEdit() ) )
+ {
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ pOLV->Read( *xStm, String(), EE_FORMAT_RTF, sal_False, mpDocSh->GetHeaderAttributes() );
+ bReturn = sal_True;
+ }
+ }
+
+ if( !bReturn )
+ // mba: clipboard always must contain absolute URLs (could be from alien source)
+ bReturn = SdrView::Paste( *xStm, String(), EE_FORMAT_RTF, maDropPos, pPage, nPasteOptions );
+ }
+ }
+ }
+ else if( CHECK_FORMAT_TRANS( FORMAT_FILE_LIST ) )
+ {
+ FileList aDropFileList;
+
+ if( aDataHelper.GetFileList( FORMAT_FILE_LIST, aDropFileList ) )
+ {
+ maDropFileVector.clear();
+
+ for( sal_uLong i = 0, nCount = aDropFileList.Count(); i < nCount; i++ )
+ maDropFileVector.push_back( aDropFileList.GetFile( i ) );
+
+ maDropInsertFileTimer.Start();
+ }
+
+ bReturn = sal_True;
+ }
+ else if( CHECK_FORMAT_TRANS( FORMAT_FILE ) )
+ {
+ String aDropFile;
+
+ if( aDataHelper.GetString( FORMAT_FILE, aDropFile ) )
+ {
+ maDropFileVector.clear();
+ maDropFileVector.push_back( aDropFile );
+ maDropInsertFileTimer.Start();
+ }
+
+ bReturn = sal_True;
+ }
+ else if( !bLink && CHECK_FORMAT_TRANS( FORMAT_STRING ) )
+ {
+ if( ( FORMAT_STRING == nFormat ) ||
+ ( !aDataHelper.HasFormat( SOT_FORMATSTR_ID_SOLK ) &&
+ !aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
+ !aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILENAME ) ) )
+ {
+ ::rtl::OUString aOUString;
+
+ if( aDataHelper.GetString( FORMAT_STRING, aOUString ) )
+ {
+ OutlinerView* pOLV = GetTextEditOutlinerView();
+
+ if( pOLV )
+ {
+ pOLV->InsertText( aOUString );
+ bReturn = sal_True;
+ }
+
+ if( !bReturn )
+ bReturn = SdrView::Paste( aOUString, maDropPos, pPage, nPasteOptions );
+ }
+ }
+ }
+
+ MarkListHasChanged();
+ mbIsDropAllowed = sal_True;
+ rDnDAction = mnAction;
+ delete pImageMap;
+
+ return bReturn;
+}
+
+extern void CreateTableFromRTF( SvStream& rStream, SdDrawDocument* pModel );
+
+bool View::PasteRTFTable( SotStorageStreamRef xStm, SdrPage* pPage, sal_uLong nPasteOptions )
+{
+ SdDrawDocument* pModel = new SdDrawDocument( DOCUMENT_TYPE_IMPRESS, mpDocSh );
+ pModel->NewOrLoadCompleted(NEW_DOC);
+ pModel->GetItemPool().SetDefaultMetric(SFX_MAPUNIT_100TH_MM);
+ pModel->InsertPage(pModel->AllocPage(false));
+
+ Reference< XComponent > xComponent( new SdXImpressDocument( pModel, sal_True ) );
+ pModel->setUnoModel( Reference< XInterface >::query( xComponent ) );
+
+ CreateTableFromRTF( *xStm, pModel );
+ bool bRet = Paste( *pModel, maDropPos, pPage, nPasteOptions );
+
+ xComponent->dispose();
+ xComponent.clear();
+
+ delete pModel;
+
+ return bRet;
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx
new file mode 100755
index 000000000000..74719ce968d2
--- /dev/null
+++ b/sd/source/ui/view/sdview4.cxx
@@ -0,0 +1,638 @@
+/*************************************************************************
+ *
+ * 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 "View.hxx"
+#include <unotools/localfilehelper.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/docfile.hxx>
+#include <vcl/msgbox.hxx>
+#include <svl/urlbmk.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/xfillit.hxx>
+#include <svx/svdundo.hxx>
+#include <svx/xoutbmp.hxx>
+#include <svx/svdograf.hxx>
+#include <svx/svdomedia.hxx>
+#include <svx/svdoole2.hxx>
+#include <sot/storage.hxx>
+#include <sfx2/app.hxx>
+#include <avmedia/mediawindow.hxx>
+#include <svtools/ehdl.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svtools/filter.hxx>
+#include "app.hrc"
+#include "Window.hxx"
+#include "DrawDocShell.hxx"
+#include "DrawViewShell.hxx"
+#include "fuinsfil.hxx"
+#include "drawdoc.hxx"
+#include "sdresid.hxx"
+#include "strings.hrc"
+#include "imapinfo.hxx"
+#include "sdpage.hxx"
+#include "view/SlideSorterView.hxx"
+#include "undo/undoobjects.hxx"
+
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/embed/XEmbedPersist.hpp>
+#include <com/sun/star/embed/Aspects.hpp>
+#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <svtools/soerr.hxx>
+
+#include <sfx2/ipclient.hxx>
+
+using namespace com::sun::star;
+
+namespace sd {
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+/*************************************************************************
+|*
+|* Graphik einfuegen
+|* Wird ein leeres Graphikobjekt uebergeben, so wird dieses gefuellt.
+|* Andernfalls wird ein an der gegebenen Position vorhandenes Objekt
+|* gefuellt. Ist an der Position kein Objekt vorhanden, so wird ein neues
+|* Objekt erzeugt und ein Pointer auf dieses Objekt zurueckgegeben.
+|*
+\************************************************************************/
+
+SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction,
+ const Point& rPos, SdrObject* pObj, ImageMap* pImageMap )
+{
+ SdrEndTextEdit();
+ mnAction = rAction;
+
+ // Liegt ein Objekt an der Position rPos?
+ SdrGrafObj* pNewGrafObj = NULL;
+ SdrPageView* pPV = GetSdrPageView();
+ SdrObject* pPickObj = pObj;
+ const bool bOnMaster = pPV && pPV->GetPage() && pPV->GetPage()->IsMasterPage();
+
+ if(pPV && this->ISA(::sd::slidesorter::view::SlideSorterView))
+ {
+ if(!pPV->GetPageRect().IsInside(rPos))
+ pPV = 0L;
+ }
+
+ if( !pPickObj && pPV )
+ {
+ SdrPageView* pPageView = pPV;
+ PickObj(rPos, getHitTolLog(), pPickObj, pPageView);
+ }
+
+ if( mnAction == DND_ACTION_LINK && pPickObj && pPV )
+ {
+ const bool bIsGraphic = pPickObj->ISA( SdrGrafObj );
+ if( bIsGraphic || (pObj->IsEmptyPresObj() && !bOnMaster) )
+ {
+ if( IsUndoEnabled() )
+ BegUndo(String(SdResId(STR_INSERTGRAPHIC)));
+
+ SdPage* pPage = (SdPage*) pPickObj->GetPage();
+
+ if( bIsGraphic )
+ {
+ // Das Objekt wird mit der Bitmap gefuellt
+ pNewGrafObj = (SdrGrafObj*) pPickObj->Clone();
+ pNewGrafObj->SetGraphic(rGraphic);
+ }
+ else
+ {
+ pNewGrafObj = new SdrGrafObj( rGraphic, pPickObj->GetLogicRect() );
+ pNewGrafObj->SetEmptyPresObj(sal_True);
+ }
+
+ if ( pNewGrafObj->IsEmptyPresObj() )
+ {
+ Rectangle aRect( pNewGrafObj->GetLogicRect() );
+ pNewGrafObj->AdjustToMaxRect( aRect, sal_False );
+ pNewGrafObj->SetOutlinerParaObject(NULL);
+ pNewGrafObj->SetEmptyPresObj(sal_False);
+ }
+
+ if (pPage && pPage->IsPresObj(pPickObj))
+ {
+ // Neues PresObj in die Liste eintragen
+ pPage->InsertPresObj( pNewGrafObj, PRESOBJ_GRAPHIC );
+ pNewGrafObj->SetUserCall(pPickObj->GetUserCall());
+ }
+
+ if (pImageMap)
+ pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap));
+
+ ReplaceObjectAtView(pPickObj, *pPV, pNewGrafObj); // maybe ReplaceObjectAtView
+
+ if( IsUndoEnabled() )
+ EndUndo();
+ }
+ else if (pPickObj->IsClosedObj() && !pPickObj->ISA(SdrOle2Obj))
+ {
+ /******************************************************************
+ * Das Objekt wird mit der Graphik gefuellt
+ ******************************************************************/
+ if( IsUndoEnabled() )
+ {
+ BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+ AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoAttrObject(*pPickObj));
+ EndUndo();
+ }
+
+ XOBitmap aXOBitmap( rGraphic.GetBitmap() );
+ SfxItemSet aSet(mpDocSh->GetPool(), XATTR_FILLSTYLE, XATTR_FILLBITMAP);
+ aSet.Put(XFillStyleItem(XFILL_BITMAP));
+ aSet.Put(XFillBitmapItem(&mpDocSh->GetPool(), aXOBitmap));
+ pPickObj->SetMergedItemSetAndBroadcast(aSet);
+ }
+ }
+ else if ( pPV )
+ {
+ // create new object
+ Size aSize;
+
+ if ( rGraphic.GetPrefMapMode().GetMapUnit() == MAP_PIXEL )
+ {
+ ::OutputDevice* pOutDev = 0;
+ if( mpViewSh )
+ pOutDev = mpViewSh->GetActiveWindow();
+
+ if( !pOutDev )
+ pOutDev = Application::GetDefaultDevice();
+
+ if( pOutDev )
+ aSize = pOutDev->PixelToLogic( rGraphic.GetPrefSize(), MAP_100TH_MM );
+ }
+ else
+ {
+ aSize = OutputDevice::LogicToLogic( rGraphic.GetPrefSize(),
+ rGraphic.GetPrefMapMode(),
+ MapMode( MAP_100TH_MM ) );
+ }
+
+ pNewGrafObj = new SdrGrafObj( rGraphic, Rectangle( rPos, aSize ) );
+ SdrPage* pPage = pPV->GetPage();
+ Size aPageSize( pPage->GetSize() );
+ aPageSize.Width() -= pPage->GetLftBorder() + pPage->GetRgtBorder();
+ aPageSize.Height() -= pPage->GetUppBorder() + pPage->GetLwrBorder();
+ pNewGrafObj->AdjustToMaxRect( Rectangle( Point(), aPageSize ), sal_True );
+// pNewGrafObj->AdjustToMaxRect( Rectangle( pPV->GetOffset(), aPageSize ), sal_True );
+
+ sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
+ sal_Bool bIsPresTarget = sal_False;
+
+ if ((mpViewSh
+ && mpViewSh->GetViewShell()!=NULL
+ && mpViewSh->GetViewShell()->GetIPClient()
+ && mpViewSh->GetViewShell()->GetIPClient()->IsObjectInPlaceActive())
+ || this->ISA(::sd::slidesorter::view::SlideSorterView))
+ nOptions |= SDRINSERT_DONTMARK;
+
+ if( ( mnAction & DND_ACTION_MOVE ) && pPickObj && (pPickObj->IsEmptyPresObj() || pPickObj->GetUserCall()) )
+ {
+ SdPage* pP = static_cast< SdPage* >( pPickObj->GetPage() );
+
+ if ( pP && pP->IsMasterPage() )
+ bIsPresTarget = pP->IsPresObj(pPickObj);
+ }
+
+ if( ( mnAction & DND_ACTION_MOVE ) && pPickObj && !bIsPresTarget )
+ {
+ // replace object
+ if (pImageMap)
+ pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap));
+
+ Rectangle aPickObjRect(pPickObj->GetCurrentBoundRect());
+ Size aPickObjSize(aPickObjRect.GetSize());
+ Rectangle aObjRect(pNewGrafObj->GetCurrentBoundRect());
+ Size aObjSize(aObjRect.GetSize());
+
+ Fraction aScaleWidth(aPickObjSize.Width(), aObjSize.Width());
+ Fraction aScaleHeight(aPickObjSize.Height(), aObjSize.Height());
+ pNewGrafObj->NbcResize(aObjRect.TopLeft(), aScaleWidth, aScaleHeight);
+
+ Point aVec = aPickObjRect.TopLeft() - aObjRect.TopLeft();
+ pNewGrafObj->NbcMove(Size(aVec.X(), aVec.Y()));
+
+ const bool bUndo = IsUndoEnabled();
+
+ if( bUndo )
+ BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+ pNewGrafObj->NbcSetLayer(pPickObj->GetLayer());
+ SdrPage* pP = pPV->GetPage();
+ pP->InsertObject(pNewGrafObj);
+ if( bUndo )
+ {
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoNewObject(*pNewGrafObj));
+ AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pPickObj));
+ }
+ pP->RemoveObject(pPickObj->GetOrdNum());
+
+ if( bUndo )
+ {
+ EndUndo();
+ }
+ else
+ {
+ SdrObject::Free(pPickObj);
+ }
+ mnAction = DND_ACTION_COPY;
+ }
+ else
+ {
+ InsertObjectAtView(pNewGrafObj, *pPV, nOptions);
+
+ if( pImageMap )
+ pNewGrafObj->InsertUserData(new SdIMapInfo(*pImageMap));
+ }
+ }
+
+ rAction = mnAction;
+
+ return pNewGrafObj;
+}
+
+// -----------------------------------------------------------------------------
+
+SdrMediaObj* View::InsertMediaURL( const rtl::OUString& rMediaURL, sal_Int8& rAction,
+ const Point& rPos, const Size& rSize )
+{
+ SdrEndTextEdit();
+ mnAction = rAction;
+
+ SdrMediaObj* pNewMediaObj = NULL;
+ SdrPageView* pPV = GetSdrPageView();
+ SdrObject* pPickObj = GetEmptyPresentationObject( PRESOBJ_MEDIA );
+
+ if(pPV && this->ISA(::sd::slidesorter::view::SlideSorterView ))
+ {
+ if(!pPV->GetPageRect().IsInside(rPos))
+ pPV = 0L;
+ }
+
+ if( !pPickObj && pPV )
+ {
+ SdrPageView* pPageView = pPV;
+ PickObj(rPos, getHitTolLog(), pPickObj, pPageView);
+ }
+
+ if( mnAction == DND_ACTION_LINK && pPickObj && pPV && pPickObj->ISA( SdrMediaObj ) )
+ {
+ pNewMediaObj = static_cast< SdrMediaObj* >( pPickObj->Clone() );
+ pNewMediaObj->setURL( rMediaURL );
+
+ BegUndo(String(SdResId(STR_UNDO_DRAGDROP)));
+ ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
+ EndUndo();
+ }
+ else if( pPV )
+ {
+ Rectangle aRect( rPos, rSize );
+ if( pPickObj )
+ aRect = pPickObj->GetLogicRect();
+
+
+ pNewMediaObj = new SdrMediaObj( aRect );
+
+ bool bIsPres = false;
+ if( pPickObj )
+ {
+ SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
+ bIsPres = pPage && pPage->IsPresObj(pPickObj);
+ if( bIsPres )
+ {
+ pPage->InsertPresObj( pNewMediaObj, PRESOBJ_MEDIA );
+ }
+ }
+
+ if( pPickObj )
+ ReplaceObjectAtView(pPickObj, *pPV, pNewMediaObj);
+ else
+ InsertObjectAtView( pNewMediaObj, *pPV, SDRINSERT_SETDEFLAYER );
+
+ pNewMediaObj->setURL( rMediaURL );
+
+ if( pPickObj )
+ {
+ pNewMediaObj->AdjustToMaxRect( pPickObj->GetLogicRect() );
+ if( bIsPres )
+ pNewMediaObj->SetUserCall(pPickObj->GetUserCall());
+ }
+ }
+
+ rAction = mnAction;
+
+ return pNewMediaObj;
+}
+
+/*************************************************************************
+|*
+|* Timer-Handler fuer InsertFile beim Drop()
+|*
+\************************************************************************/
+
+IMPL_LINK( View, DropInsertFileHdl, Timer*, EMPTYARG )
+{
+ DBG_ASSERT( mpViewSh, "sd::View::DropInsertFileHdl(), I need a view shell to work!" );
+ if( !mpViewSh )
+ return 0;
+
+ SfxErrorContext aEc( ERRCTX_ERROR, mpViewSh->GetActiveWindow(), RID_SO_ERRCTX );
+ ErrCode nError = 0;
+
+ ::std::vector< String >::const_iterator aIter( maDropFileVector.begin() );
+
+ while( (aIter != maDropFileVector.end()) && !nError )
+ {
+ String aCurrentDropFile( *aIter );
+ INetURLObject aURL( aCurrentDropFile );
+ sal_Bool bOK = sal_False;
+
+ if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
+ {
+ String aURLStr;
+ ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aCurrentDropFile, aURLStr );
+ aURL = INetURLObject( aURLStr );
+ }
+
+ GraphicFilter* pGraphicFilter = GraphicFilter::GetGraphicFilter();
+ Graphic aGraphic;
+
+ aCurrentDropFile = aURL.GetMainURL( INetURLObject::NO_DECODE );
+
+ if( !::avmedia::MediaWindow::isMediaURL( aCurrentDropFile ) )
+ {
+ if( !pGraphicFilter->ImportGraphic( aGraphic, aURL ) )
+ {
+ sal_Int8 nTempAction = ( aIter == maDropFileVector.begin() ) ? mnAction : 0;
+ const bool bLink = ( ( nTempAction & DND_ACTION_LINK ) != 0 );
+ SdrGrafObj* pGrafObj = InsertGraphic( aGraphic, nTempAction, maDropPos, NULL, NULL );
+
+ if( pGrafObj && bLink )
+ pGrafObj->SetGraphicLink( aCurrentDropFile, String() );
+
+ // return action from first inserted graphic
+ if( aIter == maDropFileVector.begin() )
+ mnAction = nTempAction;
+
+ bOK = sal_True;
+ }
+ if( !bOK )
+ {
+ const SfxFilter* pFoundFilter = NULL;
+ SfxMedium aSfxMedium( aCurrentDropFile, STREAM_READ | STREAM_SHARE_DENYNONE, sal_False );
+ ErrCode nErr = SFX_APP()->GetFilterMatcher().GuessFilter( aSfxMedium, &pFoundFilter, SFX_FILTER_IMPORT, SFX_FILTER_NOTINSTALLED | SFX_FILTER_EXECUTABLE );
+
+ if( pFoundFilter && !nErr )
+ {
+ ::std::vector< String > aFilterVector;
+ const String aFilterName( pFoundFilter->GetFilterName() );
+ String aLowerAsciiFileName( aCurrentDropFile );
+ aLowerAsciiFileName.ToLowerAscii();
+
+ FuInsertFile::GetSupportedFilterVector( aFilterVector );
+
+ if( ( ::std::find( aFilterVector.begin(), aFilterVector.end(), pFoundFilter->GetMimeType() ) != aFilterVector.end() ) ||
+ aFilterName.SearchAscii( "Text" ) != STRING_NOTFOUND ||
+ aFilterName.SearchAscii( "Rich" ) != STRING_NOTFOUND ||
+ aFilterName.SearchAscii( "RTF" ) != STRING_NOTFOUND ||
+ aFilterName.SearchAscii( "HTML" ) != STRING_NOTFOUND ||
+ aLowerAsciiFileName.SearchAscii(".sdd") != STRING_NOTFOUND ||
+ aLowerAsciiFileName.SearchAscii(".sda") != STRING_NOTFOUND ||
+ aLowerAsciiFileName.SearchAscii(".sxd") != STRING_NOTFOUND ||
+ aLowerAsciiFileName.SearchAscii(".sxi") != STRING_NOTFOUND ||
+ aLowerAsciiFileName.SearchAscii(".std") != STRING_NOTFOUND ||
+ aLowerAsciiFileName.SearchAscii(".sti") != STRING_NOTFOUND )
+ {
+ ::sd::Window* pWin = mpViewSh->GetActiveWindow();
+ SfxRequest aReq(SID_INSERTFILE, 0, mpDoc->GetItemPool());
+ SfxStringItem aItem1( ID_VAL_DUMMY0, aCurrentDropFile ), aItem2( ID_VAL_DUMMY1, pFoundFilter->GetFilterName() );
+
+ aReq.AppendItem( aItem1 );
+ aReq.AppendItem( aItem2 );
+ FuInsertFile::Create( mpViewSh, pWin, this, mpDoc, aReq );
+ bOK = sal_True;
+ }
+ }
+ }
+ }
+
+ if( !bOK )
+ {
+ Size aPrefSize;
+
+ if( ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile ) &&
+ ::avmedia::MediaWindow::isMediaURL( aCurrentDropFile, true, &aPrefSize ) )
+ {
+ if( aPrefSize.Width() && aPrefSize.Height() )
+ {
+ ::sd::Window* pWin = mpViewSh->GetActiveWindow();
+
+ if( pWin )
+ aPrefSize = pWin->PixelToLogic( aPrefSize, MAP_100TH_MM );
+ else
+ aPrefSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM );
+ }
+ else
+ aPrefSize = Size( 5000, 5000 );
+
+ InsertMediaURL( aCurrentDropFile, mnAction, maDropPos, aPrefSize ) ;
+ }
+ else if( mnAction & DND_ACTION_LINK )
+ static_cast< DrawViewShell* >( mpViewSh )->InsertURLButton( aCurrentDropFile, aCurrentDropFile, String(), &maDropPos );
+ else
+ {
+ if( mpViewSh )
+ {
+ try
+ {
+ //TODO/MBA: testing
+ ::rtl::OUString aName;
+ uno::Sequence < beans::PropertyValue > aMedium(1);
+ aMedium[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+ aMedium[0].Value <<= ::rtl::OUString( aCurrentDropFile );
+
+ uno::Reference < embed::XEmbeddedObject > xObj = mpDocSh->GetEmbeddedObjectContainer().
+ InsertEmbeddedObject( aMedium, aName );
+
+ uno::Reference < embed::XEmbedPersist > xPersist( xObj, uno::UNO_QUERY );
+ if ( xPersist.is())
+ {
+ // TODO/LEAN: VisualArea access can switch the object to running state
+ sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
+
+ xPersist->storeOwn();
+
+ awt::Size aSz;
+ try
+ {
+ aSz = xObj->getVisualAreaSize( nAspect );
+ }
+ catch( embed::NoVisualAreaSizeException& )
+ {
+ // the default size will be set later
+ }
+
+ Size aSize( aSz.Width, aSz.Height );
+ Rectangle aRect;
+
+ if (!aSize.Width() || !aSize.Height())
+ {
+ aSize.Width() = 1410;
+ aSize.Height() = 1000;
+ }
+
+ aRect = Rectangle( maDropPos, aSize );
+
+ SdrOle2Obj* pOleObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect );
+ sal_uLong nOptions = SDRINSERT_SETDEFLAYER;
+
+ if (mpViewSh != NULL)
+ {
+ OSL_ASSERT (mpViewSh->GetViewShell()!=NULL);
+ SfxInPlaceClient* pIpClient =
+ mpViewSh->GetViewShell()->GetIPClient();
+ if (pIpClient!=NULL && pIpClient->IsObjectInPlaceActive())
+ nOptions |= SDRINSERT_DONTMARK;
+ }
+
+ InsertObjectAtView( pOleObj, *GetSdrPageView(), nOptions );
+ pOleObj->SetLogicRect( aRect );
+ aSz.Width = aRect.GetWidth();
+ aSz.Height = aRect.GetHeight();
+ xObj->setVisualAreaSize( nAspect,aSz );
+ }
+ }
+ catch( uno::Exception& )
+ {
+ nError = ERRCODE_IO_GENERAL;
+ // TODO/LATER: better error handling
+ }
+ }
+ }
+ }
+
+ ++aIter;
+ }
+
+ if( nError )
+ ErrorHandler::HandleError( nError );
+
+ return nError;
+}
+
+/*************************************************************************
+|*
+|* Timer-Handler fuer Errorhandling beim Drop()
+|*
+\************************************************************************/
+
+IMPL_LINK( View, DropErrorHdl, Timer*, EMPTYARG )
+{
+ InfoBox( mpViewSh ? mpViewSh->GetActiveWindow() : 0, String(SdResId(STR_ACTION_NOTPOSSIBLE) ) ).Execute();
+ return 0;
+}
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+/*************************************************************************
+|*
+|* Redraw sperren oder erlauben
+|*
+\************************************************************************/
+
+void View::LockRedraw(sal_Bool bLock)
+{
+ if (bLock)
+ {
+ mnLockRedrawSmph++;
+ DBG_ASSERT(mnLockRedrawSmph, "Ueberlauf im LockRedraw");
+ }
+ else
+ {
+ DBG_ASSERT(mnLockRedrawSmph, "Unterlauf im LockRedraw");
+ mnLockRedrawSmph--;
+
+ // alle gespeicherten Redraws ausfuehren
+ if (!mnLockRedrawSmph)
+ {
+ while (mpLockedRedraws && mpLockedRedraws->Count())
+ {
+ SdViewRedrawRec* pRec = (SdViewRedrawRec*)mpLockedRedraws->First();
+ OutputDevice* pCurrentOut = pRec->mpOut;
+ Rectangle aBoundRect(pRec->aRect);
+ mpLockedRedraws->Remove(pRec);
+ delete pRec;
+
+ pRec = (SdViewRedrawRec*)mpLockedRedraws->First();
+ while (pRec)
+ {
+ if (pRec->mpOut == pCurrentOut)
+ {
+ aBoundRect.Union(pRec->aRect);
+ mpLockedRedraws->Remove(pRec);
+ delete pRec;
+ pRec = (SdViewRedrawRec*)mpLockedRedraws->GetCurObject();
+ }
+ else
+ {
+ pRec = (SdViewRedrawRec*)mpLockedRedraws->Next();
+ }
+ }
+
+ CompleteRedraw(pCurrentOut, Region(aBoundRect));
+ }
+ delete mpLockedRedraws;
+ mpLockedRedraws = NULL;
+ }
+ }
+}
+
+
+
+
+/*************************************************************************
+|*
+|* StyleSheet aus der Sleketion besorgen
+|*
+\************************************************************************/
+
+SfxStyleSheet* View::GetStyleSheet() const
+{
+ return SdrView::GetStyleSheet();
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/sdview5.cxx b/sd/source/ui/view/sdview5.cxx
new file mode 100755
index 000000000000..c84f098b3269
--- /dev/null
+++ b/sd/source/ui/view/sdview5.cxx
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * 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 "sdpage.hxx"
+#include "View.hxx"
+#include "pres.hxx"
+
+namespace sd {
+
+static bool implIsMultiPresObj( PresObjKind eKind )
+{
+ switch( eKind )
+ {
+ case PRESOBJ_OUTLINE:
+ case PRESOBJ_GRAPHIC:
+ case PRESOBJ_OBJECT:
+ case PRESOBJ_CHART:
+ case PRESOBJ_ORGCHART:
+ case PRESOBJ_TABLE:
+ case PRESOBJ_IMAGE:
+ case PRESOBJ_MEDIA:
+ return true;
+ default:
+ return false;
+ }
+}
+
+SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind )
+{
+ SdrObject* pEmptyObj = 0;
+
+ SdrPageView* pPV = GetSdrPageView();
+ if( pPV )
+ {
+ SdPage* pPage = static_cast< SdPage* >( pPV->GetPage() );
+ if( pPage && !pPage->IsMasterPage() )
+ {
+ // first try selected shape
+ if ( AreObjectsMarked() )
+ {
+ /**********************************************************
+ * Is an empty graphic object available?
+ **********************************************************/
+ const SdrMarkList& rMarkList = GetMarkedObjectList();
+
+ if (rMarkList.GetMarkCount() == 1)
+ {
+ SdrMark* pMark = rMarkList.GetMark(0);
+ SdrObject* pObj = pMark->GetMarkedSdrObj();
+
+ if( pObj->IsEmptyPresObj() && implIsMultiPresObj( pPage->GetPresObjKind(pObj) ) )
+ pEmptyObj = pObj;
+ }
+ }
+
+ // try to find empty pres obj of same type
+ if( !pEmptyObj )
+ {
+ int nIndex = 1;
+ do
+ {
+ pEmptyObj = pPage->GetPresObj(eKind, nIndex++ );
+ }
+ while( (pEmptyObj != 0) && (!pEmptyObj->IsEmptyPresObj()) );
+ }
+
+ // last try to find empty pres obj of multiple type
+ if( !pEmptyObj )
+ {
+ const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();
+
+ for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); iter++ )
+ {
+ if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) )
+ {
+ pEmptyObj = (*iter);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return pEmptyObj;
+}
+
+}
diff --git a/sd/source/ui/view/sdwindow.cxx b/sd/source/ui/view/sdwindow.cxx
new file mode 100755
index 000000000000..a9830295a9ec
--- /dev/null
+++ b/sd/source/ui/view/sdwindow.cxx
@@ -0,0 +1,1210 @@
+/*************************************************************************
+ *
+ * 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 "Window.hxx"
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+
+#include <sfx2/viewfrm.hxx>
+#include <svx/svxids.hrc>
+
+#include <editeng/outliner.hxx>
+#include <editeng/editview.hxx>
+
+#include "app.hrc"
+#include "helpids.h"
+#include "ViewShell.hxx"
+#include "DrawViewShell.hxx"
+#include "View.hxx"
+#include "FrameView.hxx"
+#include "OutlineViewShell.hxx"
+#include "drawdoc.hxx"
+#include "AccessibleDrawDocumentView.hxx"
+#include "WindowUpdater.hxx"
+
+namespace sd {
+
+#define SCROLL_LINE_FACT 0.05 // Faktor fuer Zeilenscrolling
+#define SCROLL_PAGE_FACT 0.5 // Faktor fuer Seitenscrolling
+#define SCROLL_SENSITIVE 20 // Sensitiver Bereich (Pixel)
+#define ZOOM_MULTIPLICATOR 10000 // Multiplikator um Rundungsfehler zu vermeiden
+#define MIN_ZOOM 5 // Minimaler Zoomfaktor
+#define MAX_ZOOM 3000 // Maximaler Zoomfaktor
+
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+Window::Window(::Window* pParent)
+ : ::Window(pParent, WinBits(WB_CLIPCHILDREN | WB_DIALOGCONTROL)),
+ DropTargetHelper( this ),
+ mpShareWin(NULL),
+ maWinPos(0, 0), // vorsichtshalber; die Werte sollten aber
+ maViewOrigin(0, 0), // vom Besitzer des Fensters neu gesetzt
+ maViewSize(1000, 1000), // werden
+ mnMinZoom(MIN_ZOOM),
+ mnMaxZoom(MAX_ZOOM),
+ mbMinZoomAutoCalc(false),
+ mbCalcMinZoomByMinSide(true),
+ mbCenterAllowed(true),
+ mnTicks (0),
+ mbDraggedFrom(false),
+ mpViewShell(NULL),
+ mbUseDropScroll (true)
+{
+ SetDialogControlFlags( WINDOW_DLGCTRL_RETURN | WINDOW_DLGCTRL_WANTFOCUS );
+
+ MapMode aMap(GetMapMode());
+ aMap.SetMapUnit(MAP_100TH_MM);
+ SetMapMode(aMap);
+
+ // Damit im Diamodus die ::WindowColor genommen wird
+ SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetWindowColor() ) );
+
+ // adjust contrast mode initially
+ bool bUseContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+ SetDrawMode( bUseContrast
+ ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
+ : ViewShell::OUTPUT_DRAWMODE_COLOR );
+
+ // Hilfe-ID setzen
+ // SetHelpId(HID_SD_WIN_DOCUMENT);
+ SetUniqueId(HID_SD_WIN_DOCUMENT);
+
+ // #i78183# Added after discussed with AF
+ EnableRTL(sal_False);
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+Window::~Window (void)
+{
+ if (mpViewShell != NULL)
+ {
+ WindowUpdater* pWindowUpdater = mpViewShell->GetWindowUpdater();
+ if (pWindowUpdater != NULL)
+ pWindowUpdater->UnregisterWindow (this);
+ }
+}
+
+
+
+
+void Window::SetViewShell (ViewShell* pViewSh)
+{
+ WindowUpdater* pWindowUpdater = NULL;
+ // Unregister at device updater of old view shell.
+ if (mpViewShell != NULL)
+ {
+ pWindowUpdater = mpViewShell->GetWindowUpdater();
+ if (pWindowUpdater != NULL)
+ pWindowUpdater->UnregisterWindow (this);
+ }
+
+ mpViewShell = pViewSh;
+
+ // Register at device updater of new view shell
+ if (mpViewShell != NULL)
+ {
+ pWindowUpdater = mpViewShell->GetWindowUpdater();
+ if (pWindowUpdater != NULL)
+ pWindowUpdater->RegisterWindow (this);
+ }
+}
+
+void Window::CalcMinZoom()
+{
+ // Are we entitled to change the minimal zoom factor?
+ if ( mbMinZoomAutoCalc )
+ {
+ // Get current zoom factor.
+ long nZoom = GetZoom();
+
+ if ( mpShareWin )
+ {
+ mpShareWin->CalcMinZoom();
+ mnMinZoom = mpShareWin->mnMinZoom;
+ }
+ else
+ {
+ // Get the rectangle of the output area in logical coordinates
+ // and calculate the scaling factors that would lead to the view
+ // area (also called application area) to completely fill the
+ // window.
+ Size aWinSize = PixelToLogic(GetOutputSizePixel());
+ sal_uLong nX = (sal_uLong) ((double) aWinSize.Width()
+ * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Width());
+ sal_uLong nY = (sal_uLong) ((double) aWinSize.Height()
+ * (double) ZOOM_MULTIPLICATOR / (double) maViewSize.Height());
+
+ // Decide whether to take the larger or the smaller factor.
+ sal_uLong nFact;
+ if (mbCalcMinZoomByMinSide)
+ nFact = Min(nX, nY);
+ else
+ nFact = Max(nX, nY);
+
+ // The factor is tansfomed according to the current zoom factor.
+ nFact = nFact * nZoom / ZOOM_MULTIPLICATOR;
+ mnMinZoom = Max((sal_uInt16) MIN_ZOOM, (sal_uInt16) nFact);
+ }
+ // If the current zoom factor is smaller than the calculated minimal
+ // zoom factor then set the new minimal factor as the current zoom
+ // factor.
+ if ( nZoom < (long) mnMinZoom )
+ SetZoomFactor(mnMinZoom);
+ }
+}
+
+
+
+
+void Window::SetMinZoom (long int nMin)
+{
+ mnMinZoom = (sal_uInt16) nMin;
+}
+
+
+
+
+long Window::GetMinZoom (void) const
+{
+ return mnMinZoom;
+}
+
+
+
+
+void Window::SetMaxZoom (long int nMax)
+{
+ mnMaxZoom = (sal_uInt16) nMax;
+}
+
+
+
+
+long Window::GetMaxZoom (void) const
+{
+ return mnMaxZoom;
+}
+
+
+
+
+long Window::GetZoom (void) const
+{
+ if( GetMapMode().GetScaleX().GetDenominator() )
+ {
+ return GetMapMode().GetScaleX().GetNumerator() * 100L
+ / GetMapMode().GetScaleX().GetDenominator();
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Resize event
+|*
+\************************************************************************/
+
+void Window::Resize()
+{
+ ::Window::Resize();
+ CalcMinZoom();
+
+ if( mpViewShell && mpViewShell->GetViewFrame() )
+ mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
+}
+
+/*************************************************************************
+|*
+|* PrePaint event
+|*
+\************************************************************************/
+
+void Window::PrePaint()
+{
+ if ( mpViewShell )
+ mpViewShell->PrePaint();
+}
+
+/*************************************************************************
+|*
+|* Paint event
+|*
+\************************************************************************/
+
+void Window::Paint(const Rectangle& rRect)
+{
+ if ( mpViewShell )
+ mpViewShell->Paint(rRect, this);
+}
+
+/*************************************************************************
+|*
+|* Keyboard event
+|*
+\************************************************************************/
+
+void Window::KeyInput(const KeyEvent& rKEvt)
+{
+ if (!(mpViewShell && mpViewShell->KeyInput(rKEvt, this)))
+ {
+ if (mpViewShell && rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE)
+ {
+ mpViewShell->GetViewShell()->Escape();
+ }
+ else
+ {
+ ::Window::KeyInput(rKEvt);
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown event
+|*
+\************************************************************************/
+
+void Window::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ if ( mpViewShell )
+ mpViewShell->MouseButtonDown(rMEvt, this);
+}
+
+/*************************************************************************
+|*
+|* MouseMove event
+|*
+\************************************************************************/
+
+void Window::MouseMove(const MouseEvent& rMEvt)
+{
+ if ( mpViewShell )
+ mpViewShell->MouseMove(rMEvt, this);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp event
+|*
+\************************************************************************/
+
+void Window::MouseButtonUp(const MouseEvent& rMEvt)
+{
+ mnTicks = 0;
+
+ if ( mpViewShell )
+ mpViewShell->MouseButtonUp(rMEvt, this);
+}
+
+/*************************************************************************
+|*
+|* Command event
+|*
+\************************************************************************/
+
+void Window::Command(const CommandEvent& rCEvt)
+{
+ if ( mpViewShell )
+ mpViewShell->Command(rCEvt, this);
+}
+
+long Window::Notify( NotifyEvent& rNEvt )
+{
+ long nResult = sal_False;
+ if ( mpViewShell )
+ {
+ nResult = mpViewShell->Notify(rNEvt, this);
+ }
+ if( !nResult )
+ ::Window::Notify( rNEvt );
+
+ return nResult;
+}
+
+
+/*************************************************************************
+|*
+|* RequestHelp event
+|*
+\************************************************************************/
+
+void Window::RequestHelp(const HelpEvent& rEvt)
+{
+ if ( mpViewShell )
+ {
+ if( !mpViewShell->RequestHelp( rEvt, this) )
+ ::Window::RequestHelp( rEvt );
+ }
+ else
+ ::Window::RequestHelp( rEvt );
+}
+
+
+
+
+Point Window::GetWinViewPos (void) const
+{
+ return maWinPos;
+}
+
+
+
+
+Point Window::GetViewOrigin (void) const
+{
+ return maViewOrigin;
+}
+
+
+
+
+Size Window::GetViewSize (void) const
+{
+ return maViewSize;
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Position der linken oberen Ecke des im Fenster sichtbaren Bereichs
+|* setzen
+|*
+\************************************************************************/
+
+void Window::SetWinViewPos(const Point& rPnt)
+{
+ maWinPos = rPnt;
+}
+
+/*************************************************************************
+|*
+|* Ursprung der Darstellung in Bezug zur gesamten Arbeitsflaeche setzen
+|*
+\************************************************************************/
+
+void Window::SetViewOrigin(const Point& rPnt)
+{
+ maViewOrigin = rPnt;
+}
+
+/*************************************************************************
+|*
+|* Groesse der gesamten Arbeitsflaeche, die mit dem Fenster betrachtet
+|* werden kann, setzen
+|*
+\************************************************************************/
+
+void Window::SetViewSize(const Size& rSize)
+{
+ maViewSize = rSize;
+ CalcMinZoom();
+}
+
+
+
+
+void Window::SetCenterAllowed (bool bIsAllowed)
+{
+ mbCenterAllowed = bIsAllowed;
+}
+
+
+
+
+long Window::SetZoomFactor(long nZoom)
+{
+ // Clip the zoom factor to the valid range marked by nMinZoom as
+ // calculated by CalcMinZoom() and the constant MAX_ZOOM.
+ if ( nZoom > MAX_ZOOM )
+ nZoom = MAX_ZOOM;
+ if ( nZoom < (long) mnMinZoom )
+ nZoom = mnMinZoom;
+
+ // Set the zoom factor at the window's map mode.
+ MapMode aMap(GetMapMode());
+ aMap.SetScaleX(Fraction(nZoom, 100));
+ aMap.SetScaleY(Fraction(nZoom, 100));
+ SetMapMode(aMap);
+
+ // Update the map mode's origin (to what effect?).
+ UpdateMapOrigin();
+
+ // Update the view's snapping to the the new zoom factor.
+ if ( mpViewShell && mpViewShell->ISA(DrawViewShell) )
+ ((DrawViewShell*) mpViewShell)->GetView()->
+ RecalcLogicSnapMagnetic(*this);
+
+ // Return the zoom factor just in case it has been changed above to lie
+ // inside the valid range.
+ return nZoom;
+}
+
+void Window::SetZoomIntegral(long nZoom)
+{
+ // Clip the zoom factor to the valid range marked by nMinZoom as
+ // previously calculated by <member>CalcMinZoom()</member> and the
+ // MAX_ZOOM constant.
+ if ( nZoom > MAX_ZOOM )
+ nZoom = MAX_ZOOM;
+ if ( nZoom < (long) mnMinZoom )
+ nZoom = mnMinZoom;
+
+ // Calculate the window's new origin.
+ Size aSize = PixelToLogic(GetOutputSizePixel());
+ long nW = aSize.Width() * GetZoom() / nZoom;
+ long nH = aSize.Height() * GetZoom() / nZoom;
+ maWinPos.X() += (aSize.Width() - nW) / 2;
+ maWinPos.Y() += (aSize.Height() - nH) / 2;
+ if ( maWinPos.X() < 0 ) maWinPos.X() = 0;
+ if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0;
+
+ // Finally update this window's map mode to the given zoom factor that
+ // has been clipped to the valid range.
+ SetZoomFactor(nZoom);
+}
+
+long Window::GetZoomForRect( const Rectangle& rZoomRect )
+{
+ long nRetZoom = 100;
+
+ if( (rZoomRect.GetWidth() != 0) && (rZoomRect.GetHeight() != 0))
+ {
+ // Calculate the scale factors which will lead to the given
+ // rectangle being fully visible (when translated accordingly) as
+ // large as possible in the output area independently in both
+ // coordinate directions .
+ sal_uLong nX(0L);
+ sal_uLong nY(0L);
+
+ const Size aWinSize( PixelToLogic(GetOutputSizePixel()) );
+ if(rZoomRect.GetHeight())
+ {
+ nX = (sal_uLong) ((double) aWinSize.Height()
+ * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight());
+ }
+
+ if(rZoomRect.GetWidth())
+ {
+ nY = (sal_uLong) ((double) aWinSize.Width()
+ * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth());
+ }
+
+ // Use the smaller one of both so that the zoom rectangle will be
+ // fully visible with respect to both coordinate directions.
+ sal_uLong nFact = Min(nX, nY);
+
+ // Transform the current zoom factor so that it leads to the desired
+ // scaling.
+ nRetZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
+
+ // Calculate the new origin.
+ if ( nFact == 0 )
+ {
+ // Don't change anything if the scale factor is degenrate.
+ nRetZoom = GetZoom();
+ }
+ else
+ {
+ // Clip the zoom factor to the valid range marked by nMinZoom as
+ // previously calculated by <member>CalcMinZoom()</member> and the
+ // MAX_ZOOM constant.
+ if ( nRetZoom > MAX_ZOOM )
+ nRetZoom = MAX_ZOOM;
+ if ( nRetZoom < (long) mnMinZoom )
+ nRetZoom = mnMinZoom;
+ }
+ }
+
+ return nRetZoom;
+}
+
+/** Recalculate the zoom factor and translation so that the given rectangle
+ is displayed centered and as large as possible while still being fully
+ visible in the window.
+*/
+long Window::SetZoomRect (const Rectangle& rZoomRect)
+{
+ long nNewZoom = 100;
+
+ if (rZoomRect.GetWidth() == 0 || rZoomRect.GetHeight() == 0)
+ {
+ // The given rectangle is degenerate. Use the default zoom factor
+ // (above) of 100%.
+ SetZoomIntegral(nNewZoom);
+ }
+ else
+ {
+ Point aPos = rZoomRect.TopLeft();
+ // Transform the output area from pixel coordinates into logical
+ // coordinates.
+ Size aWinSize = PixelToLogic(GetOutputSizePixel());
+ // Paranoia! The degenerate case of zero width or height has been
+ // taken care of above.
+ DBG_ASSERT(rZoomRect.GetWidth(), "ZoomRect-Breite = 0!");
+ DBG_ASSERT(rZoomRect.GetHeight(), "ZoomRect-Hoehe = 0!");
+
+ // Calculate the scale factors which will lead to the given
+ // rectangle being fully visible (when translated accordingly) as
+ // large as possible in the output area independently in both
+ // coordinate directions .
+ sal_uLong nX(0L);
+ sal_uLong nY(0L);
+
+ if(rZoomRect.GetHeight())
+ {
+ nX = (sal_uLong) ((double) aWinSize.Height()
+ * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetHeight());
+ }
+
+ if(rZoomRect.GetWidth())
+ {
+ nY = (sal_uLong) ((double) aWinSize.Width()
+ * (double) ZOOM_MULTIPLICATOR / (double) rZoomRect.GetWidth());
+ }
+
+ // Use the smaller one of both so that the zoom rectangle will be
+ // fully visible with respect to both coordinate directions.
+ sal_uLong nFact = Min(nX, nY);
+
+ // Transform the current zoom factor so that it leads to the desired
+ // scaling.
+ long nZoom = nFact * GetZoom() / ZOOM_MULTIPLICATOR;
+
+ // Calculate the new origin.
+ if ( nFact == 0 )
+ {
+ // Don't change anything if the scale factor is degenrate.
+ nNewZoom = GetZoom();
+ }
+ else
+ {
+ // Calculate the new window position that centers the given
+ // rectangle on the screen.
+ if ( nZoom > MAX_ZOOM )
+ nFact = nFact * MAX_ZOOM / nZoom;
+
+ maWinPos = maViewOrigin + aPos;
+
+ aWinSize.Width() = (long) ((double) aWinSize.Width() * (double) ZOOM_MULTIPLICATOR / (double) nFact);
+ maWinPos.X() += (rZoomRect.GetWidth() - aWinSize.Width()) / 2;
+ aWinSize.Height() = (long) ((double) aWinSize.Height() * (double) ZOOM_MULTIPLICATOR / (double) nFact);
+ maWinPos.Y() += (rZoomRect.GetHeight() - aWinSize.Height()) / 2;
+
+ if ( maWinPos.X() < 0 ) maWinPos.X() = 0;
+ if ( maWinPos.Y() < 0 ) maWinPos.Y() = 0;
+
+ // Adapt the window's map mode to the new zoom factor.
+ nNewZoom = SetZoomFactor(nZoom);
+ }
+ }
+
+ return(nNewZoom);
+}
+
+
+
+
+void Window::SetMinZoomAutoCalc (bool bAuto)
+{
+ mbMinZoomAutoCalc = bAuto;
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Neuen MapMode-Origin berechnen und setzen; wenn aWinPos.X()/Y()
+|* gleich -1 ist, wird die entsprechende Position zentriert
+|* (z.B. fuer Initialisierung)
+|*
+\************************************************************************/
+
+void Window::UpdateMapOrigin(sal_Bool bInvalidate)
+{
+ sal_Bool bChanged = sal_False;
+ Size aWinSize = PixelToLogic(GetOutputSizePixel());
+
+ if ( mbCenterAllowed )
+ {
+ if ( maWinPos.X() > maViewSize.Width() - aWinSize.Width() )
+ {
+ maWinPos.X() = maViewSize.Width() - aWinSize.Width();
+ bChanged = sal_True;
+ }
+ if ( maWinPos.Y() > maViewSize.Height() - aWinSize.Height() )
+ {
+ maWinPos.Y() = maViewSize.Height() - aWinSize.Height();
+ bChanged = sal_True;
+ }
+ if ( aWinSize.Width() > maViewSize.Width() || maWinPos.X() < 0 )
+ {
+ maWinPos.X() = maViewSize.Width() / 2 - aWinSize.Width() / 2;
+ bChanged = sal_True;
+ }
+ if ( aWinSize.Height() > maViewSize.Height() || maWinPos.Y() < 0 )
+ {
+ maWinPos.Y() = maViewSize.Height() / 2 - aWinSize.Height() / 2;
+ bChanged = sal_True;
+ }
+ }
+
+ UpdateMapMode ();
+
+ if (bChanged && bInvalidate)
+ Invalidate();
+}
+
+
+
+
+void Window::UpdateMapMode (void)
+{
+ Size aWinSize = PixelToLogic(GetOutputSizePixel());
+ maWinPos -= maViewOrigin;
+ Size aPix(maWinPos.X(), maWinPos.Y());
+ aPix = LogicToPixel(aPix);
+ // Groesse muss vielfaches von BRUSH_SIZE sein, damit Muster
+ // richtig dargestellt werden
+ // #i2237#
+ // removed old stuff here which still forced zoom to be
+ // %BRUSH_SIZE which is outdated now
+
+ if (mpViewShell && mpViewShell->ISA(DrawViewShell))
+ {
+ Size aViewSizePixel = LogicToPixel(maViewSize);
+ Size aWinSizePixel = LogicToPixel(aWinSize);
+
+ // Seite soll nicht am Fensterrand "kleben"
+ if (aPix.Width() == 0)
+ {
+ // #i2237#
+ // Since BRUSH_SIZE alignment is outdated now, i use the
+ // former constant here directly
+ aPix.Width() -= 8;
+ }
+ if (aPix.Height() == 0)
+ {
+ // #i2237#
+ // Since BRUSH_SIZE alignment is outdated now, i use the
+ // former constant here directly
+ aPix.Height() -= 8;
+ }
+ }
+
+ aPix = PixelToLogic(aPix);
+ maWinPos.X() = aPix.Width();
+ maWinPos.Y() = aPix.Height();
+ Point aNewOrigin (-maWinPos.X(), -maWinPos.Y());
+ maWinPos += maViewOrigin;
+
+ MapMode aMap(GetMapMode());
+ aMap.SetOrigin(aNewOrigin);
+ SetMapMode(aMap);
+}
+
+
+
+
+/*************************************************************************
+|*
+|* X-Position des sichtbaren Bereichs als Bruchteil (< 1)
+|* der gesamten Arbeitsbereichbreite zuruegeben
+|*
+\************************************************************************/
+
+double Window::GetVisibleX()
+{
+ return ((double) maWinPos.X() / maViewSize.Width());
+}
+
+/*************************************************************************
+|*
+|* Y-Position des sichtbaren Bereichs als Bruchteil (< 1)
+|* der gesamten Arbeitsbereichhoehe zuruegeben
+|*
+\************************************************************************/
+
+double Window::GetVisibleY()
+{
+ return ((double) maWinPos.Y() / maViewSize.Height());
+}
+
+/*************************************************************************
+|*
+|* X- und Y-Position des sichtbaren Bereichs als Bruchteile (< 1)
+|* der gesamten Arbeitsbereichgroesse setzen
+|* negative Werte werden ignoriert
+|*
+\************************************************************************/
+
+void Window::SetVisibleXY(double fX, double fY)
+{
+ long nOldX = maWinPos.X();
+ long nOldY = maWinPos.Y();
+
+ if ( fX >= 0 )
+ maWinPos.X() = (long) (fX * maViewSize.Width());
+ if ( fY >= 0 )
+ maWinPos.Y() = (long) (fY * maViewSize.Height());
+ UpdateMapOrigin(sal_False);
+ // Size sz(nOldX - aWinPos.X(), nOldY - aWinPos.Y());
+ // sz = LogicToPixel(sz);
+ Scroll(nOldX - maWinPos.X(), nOldY - maWinPos.Y(), SCROLL_CHILDREN);
+ Update();
+}
+
+/*************************************************************************
+|*
+|* Breite des sichtbaren Bereichs im Verhaeltnis zur
+|* gesamten Arbeitsbereichbreite zuruegeben
+|*
+\************************************************************************/
+
+double Window::GetVisibleWidth()
+{
+ Size aWinSize = PixelToLogic(GetOutputSizePixel());
+ if ( aWinSize.Width() > maViewSize.Width() )
+ aWinSize.Width() = maViewSize.Width();
+ return ((double) aWinSize.Width() / maViewSize.Width());
+}
+
+/*************************************************************************
+|*
+|* Hoehe des sichtbaren Bereichs im Verhaeltnis zur
+|* gesamten Arbeitsbereichhoehe zuruegeben
+|*
+\************************************************************************/
+
+double Window::GetVisibleHeight()
+{
+ Size aWinSize = PixelToLogic(GetOutputSizePixel());
+ if ( aWinSize.Height() > maViewSize.Height() )
+ aWinSize.Height() = maViewSize.Height();
+ return ((double) aWinSize.Height() / maViewSize.Height());
+}
+
+/*************************************************************************
+|*
+|* Breite einer Scrollspalte im Verhaeltnis zur gesamten
+|* Arbeitsbereichbreite zuruegeben
+|*
+\************************************************************************/
+
+double Window::GetScrlLineWidth()
+{
+ return (GetVisibleWidth() * SCROLL_LINE_FACT);
+}
+
+/*************************************************************************
+|*
+|* Breite einer Scrollspalte im Verhaeltnis zur gesamten
+|* Arbeitsbereichhoehe zuruegeben
+|*
+\************************************************************************/
+
+double Window::GetScrlLineHeight()
+{
+ return (GetVisibleHeight() * SCROLL_LINE_FACT);
+}
+
+/*************************************************************************
+|*
+|* Breite einer Scrollpage im Verhaeltnis zur gesamten
+|* Arbeitsbereichbreite zuruegeben
+|*
+\************************************************************************/
+
+double Window::GetScrlPageWidth()
+{
+ return (GetVisibleWidth() * SCROLL_PAGE_FACT);
+}
+
+/*************************************************************************
+|*
+|* Breite einer Scrollpage im Verhaeltnis zur gesamten
+|* Arbeitsbereichhoehe zuruegeben
+|*
+\************************************************************************/
+
+double Window::GetScrlPageHeight()
+{
+ return (GetVisibleHeight() * SCROLL_PAGE_FACT);
+}
+
+/*************************************************************************
+|*
+|* Fenster deaktivieren
+|*
+\************************************************************************/
+
+void Window::LoseFocus()
+{
+ mnTicks = 0;
+ ::Window::LoseFocus ();
+}
+
+/*************************************************************************
+|*
+|* Fenster aktivieren
+|*
+\************************************************************************/
+
+void Window::GrabFocus()
+{
+ mnTicks = 0;
+ ::Window::GrabFocus ();
+}
+
+
+/*************************************************************************
+|*
+|* DataChanged
+|*
+\************************************************************************/
+
+void Window::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ ::Window::DataChanged( rDCEvt );
+
+ // PRINTER bei allen Dokumenten weglassen, die keinen Printer benutzen.
+ // FONTS und FONTSUBSTITUTION weglassen, wenn keine Textausgaben
+ // vorhanden sind, bzw. wenn das Dokument keinen Text zulaesst.
+
+ if ( (rDCEvt.GetType() == DATACHANGED_PRINTER) ||
+ (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ // When the screen zoom factor has changed then reset the zoom
+ // factor of the frame to allways display the whole page.
+ const AllSettings* pOldSettings = rDCEvt.GetOldSettings ();
+ const AllSettings& rNewSettings = GetSettings ();
+ if (pOldSettings)
+ if (pOldSettings->GetStyleSettings().GetScreenZoom()
+ != rNewSettings.GetStyleSettings().GetScreenZoom())
+ mpViewShell->GetViewFrame()->GetDispatcher()->
+ Execute(SID_SIZE_PAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+
+ // ScrollBars neu anordnen bzw. Resize ausloesen, da sich
+ // ScrollBar-Groesse geaendert haben kann. Dazu muss dann im
+ // Resize-Handler aber auch die Groesse der ScrollBars aus
+ // den Settings abgefragt werden.
+ Resize();
+
+ // Daten neu Setzen, die aus den Systemeinstellungen bzw. aus
+ // den Settings uebernommen werden. Evtl. weitere Daten neu
+ // berechnen, da sich auch die Aufloesung hierdurch geaendert
+ // haben kann.
+ if( mpViewShell )
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ SvtAccessibilityOptions aAccOptions;
+ sal_uLong nOutputMode;
+ sal_uInt16 nPreviewSlot;
+
+ if( rStyleSettings.GetHighContrastMode() )
+ nOutputMode = ViewShell::OUTPUT_DRAWMODE_CONTRAST;
+ else
+ nOutputMode = ViewShell::OUTPUT_DRAWMODE_COLOR;
+
+ if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
+ nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
+ else
+ nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
+
+ if( mpViewShell->ISA( DrawViewShell ) )
+ {
+ SetDrawMode( nOutputMode );
+ mpViewShell->GetFrameView()->SetDrawMode( nOutputMode );
+// #110094#-7
+// mpViewShell->GetView()->ReleaseMasterPagePaintCache();
+ Invalidate();
+ }
+
+ // #103100# Overwrite window color for OutlineView
+ if( mpViewShell->ISA(OutlineViewShell ) )
+ {
+ svtools::ColorConfig aColorConfig;
+ const Color aDocColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor );
+ SetBackground( Wallpaper( aDocColor ) );
+ }
+
+ SfxRequest aReq( nPreviewSlot, 0, mpViewShell->GetDocSh()->GetDoc()->GetItemPool() );
+ mpViewShell->ExecReq( aReq );
+ mpViewShell->Invalidate();
+ mpViewShell->ArrangeGUIElements();
+
+ // #101928# re-create handles to show new outfit
+ if(mpViewShell->ISA(DrawViewShell))
+ {
+ mpViewShell->GetView()->AdjustMarkHdl();
+ }
+ }
+ }
+
+ if ( (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
+ ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
+ {
+ // Virtuelle Device die auch von der Aufloesung oder von
+ // Systemeinstellungen abhaengen, sollten geupdatet werden.
+ // Ansonsten sollte zumindest bei DATACHANGED_DISPLAY
+ // die virtuellen Devices geupdatet werden, da es einige
+ // Systeme erlauben die Aufloesung und Farbtiefe waehrend
+ // der Laufzeit zu aendern oder eben bei Palettenaenderungen
+ // die virtuellen Device geupdatet werden muessen, da bei
+ // Ausgaben ein anderes Farbmatching stattfinden kann.
+ }
+
+ if ( rDCEvt.GetType() == DATACHANGED_FONTS )
+ {
+ // Wenn das Dokument Font-AuswahlBoxen anbietet, muessen
+ // diese geupdatet werden. Wie dies genau aussehen muss,
+ // weiss ich leider auch nicht. Aber evtl. kann man das
+ // ja global handeln. Dies muessten wir evtl. mal
+ // mit PB absprechen, aber der ist derzeit leider Krank.
+ // Also bevor dies hier gehandelt wird, vorher mit
+ // PB und mir absprechen.
+ }
+
+ if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
+ (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) )
+ {
+ // Formatierung neu durchfuehren, da Fonts die im Dokument
+ // vorkommen, nicht mehr vorhanden sein muessen oder
+ // jetzt vorhanden sind oder durch andere ersetzt wurden
+ // sind.
+ if( mpViewShell )
+ {
+ DrawDocShell* pDocSh = mpViewShell->GetDocSh();
+ if( pDocSh )
+ pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) );
+ }
+ }
+
+ if ( rDCEvt.GetType() == DATACHANGED_PRINTER )
+ {
+ // Wie hier die Behandlung aussehen soll, weiss ich leider
+ // selbst noch nicht. Evtl. mal einen Printer loeschen und
+ // schauen was gemacht werden muss. Evtl. muesste ich in
+ // VCL dafuer noch etwas einbauen, wenn der benutze Printer
+ // geloescht wird. Ansonsten wuerde ich hier evtl. die
+ // Formatierung neu berechnen, wenn der aktuelle Drucker
+ // zerstoert wurde.
+ if( mpViewShell )
+ {
+ DrawDocShell* pDocSh = mpViewShell->GetDocSh();
+ if( pDocSh )
+ pDocSh->SetPrinter( pDocSh->GetPrinter( sal_True ) );
+ }
+ }
+
+ // Alles neu ausgeben
+ Invalidate();
+ }
+}
+
+
+
+
+/*************************************************************************
+|*
+|* DropTargetHelper::AcceptDrop
+|*
+\************************************************************************/
+
+sal_Int8 Window::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( mpViewShell && !mpViewShell->GetDocSh()->IsReadOnly() )
+ {
+ if( mpViewShell )
+ nRet = mpViewShell->AcceptDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
+
+ if (mbUseDropScroll && ! mpViewShell->ISA(OutlineViewShell))
+ DropScroll( rEvt.maPosPixel );
+ }
+
+ return nRet;
+}
+
+/*************************************************************************
+|*
+|* DropTargetHelper::ExecuteDrop
+|*
+\************************************************************************/
+
+sal_Int8 Window::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( mpViewShell )
+ {
+ nRet = mpViewShell->ExecuteDrop( rEvt, *this, this, SDRPAGE_NOTFOUND, SDRLAYER_NOTFOUND );
+ }
+
+ return nRet;
+}
+
+
+
+
+void Window::SetUseDropScroll (bool bUseDropScroll)
+{
+ mbUseDropScroll = bUseDropScroll;
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Scrolling bei AcceptDrop-Events
+|*
+\************************************************************************/
+
+void Window::DropScroll(const Point& rMousePos)
+{
+ short nDx = 0;
+ short nDy = 0;
+
+ Size aSize = GetOutputSizePixel();
+
+ if (aSize.Width() > SCROLL_SENSITIVE * 3)
+ {
+ if ( rMousePos.X() < SCROLL_SENSITIVE )
+ {
+ nDx = -1;
+ }
+
+ if ( rMousePos.X() >= aSize.Width() - SCROLL_SENSITIVE )
+ {
+ nDx = 1;
+ }
+ }
+
+ if (aSize.Height() > SCROLL_SENSITIVE * 3)
+ {
+ if ( rMousePos.Y() < SCROLL_SENSITIVE )
+ {
+ nDy = -1;
+ }
+
+ if ( rMousePos.Y() >= aSize.Height() - SCROLL_SENSITIVE )
+ {
+ nDy = 1;
+ }
+ }
+
+ if ( (nDx || nDy) && (rMousePos.X()!=0 || rMousePos.Y()!=0 ) )
+ {
+ if (mnTicks > 20)
+ mpViewShell->ScrollLines(nDx, nDy);
+ else
+ mnTicks ++;
+ }
+}
+
+
+
+
+::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ Window::CreateAccessible (void)
+{
+ if (mpViewShell != NULL)
+ return mpViewShell->CreateAccessibleDocumentView (this);
+ else
+ {
+ OSL_TRACE ("::sd::Window::CreateAccessible: no view shell");
+ return ::Window::CreateAccessible ();
+ }
+}
+
+XubString Window::GetSurroundingText() const
+{
+ if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE )
+ {
+ return XubString();
+ }
+ else if ( mpViewShell->GetView()->IsTextEdit() )
+ {
+ OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView();
+ return pOLV->GetEditView().GetSurroundingText();
+ }
+ else
+ {
+ return XubString();
+ }
+}
+
+Selection Window::GetSurroundingTextSelection() const
+{
+ if ( mpViewShell->GetShellType() == ViewShell::ST_OUTLINE )
+ {
+ return Selection( 0, 0 );
+ }
+ else if ( mpViewShell->GetView()->IsTextEdit() )
+ {
+ OutlinerView *pOLV = mpViewShell->GetView()->GetTextEditOutlinerView();
+ return pOLV->GetEditView().GetSurroundingTextSelection();
+ }
+ else
+ {
+ return Selection( 0, 0 );
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/tabcontr.cxx b/sd/source/ui/view/tabcontr.cxx
new file mode 100755
index 000000000000..150e4287bfa4
--- /dev/null
+++ b/sd/source/ui/view/tabcontr.cxx
@@ -0,0 +1,464 @@
+/*************************************************************************
+ *
+ * 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 "TabControl.hxx"
+
+#include <sfx2/viewfrm.hxx>
+#include <svx/svdlayer.hxx>
+#include <svx/svdpagv.hxx>
+#include <sfx2/dispatch.hxx>
+
+
+#include "sdattr.hxx"
+#include "app.hxx"
+#include "app.hrc"
+#include "glob.hrc"
+#include "res_bmp.hrc"
+#include "DrawViewShell.hxx"
+#include "GraphicViewShell.hxx"
+#include "helpids.h"
+#include "View.hxx"
+#include "sdpage.hxx"
+#include "drawdoc.hxx"
+#include "Window.hxx"
+#include "unmodpg.hxx"
+#include "DrawDocShell.hxx"
+#include "sdresid.hxx"
+
+
+namespace sd {
+
+#define SWITCH_TIMEOUT 20
+
+// -----------------------------------------
+// - SdTabControl::SdPageObjsTransferable -
+// -----------------------------------------
+
+TabControl::TabControlTransferable::~TabControlTransferable()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void TabControl::TabControlTransferable::AddSupportedFormats()
+{
+ AddFormat( SOT_FORMATSTR_ID_STARDRAW_TABBAR );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool TabControl::TabControlTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& )
+{
+ return sal_False;
+}
+
+// -----------------------------------------------------------------------------
+
+void TabControl::TabControlTransferable::DragFinished( sal_Int8 nDropAction )
+{
+ mrParent.DragFinished( nDropAction );
+}
+
+/*************************************************************************
+|*
+|* Standard-Konstruktor
+|*
+\************************************************************************/
+
+TabControl::TabControl(DrawViewShell* pViewSh, Window* pParent) :
+ TabBar( pParent, WinBits( WB_BORDER | WB_3DLOOK | WB_SCROLL | WB_SIZEABLE | WB_DRAG) ),
+ DragSourceHelper( this ),
+ DropTargetHelper( this ),
+ pDrViewSh(pViewSh),
+ bInternalMove(sal_False)
+{
+ EnableEditMode();
+ SetSizePixel(Size(0, 0));
+ SetMaxPageWidth( 150 );
+ SetHelpId( HID_SD_TABBAR_PAGES );
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+TabControl::~TabControl()
+{
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void TabControl::Select()
+{
+ SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher();
+ pDispatcher->Execute(SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON |
+ SFX_CALLMODE_RECORD);
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void TabControl::MouseButtonDown(const MouseEvent& rMEvt)
+{
+ if (rMEvt.IsLeft()
+ && !rMEvt.IsMod1()
+ && !rMEvt.IsMod2()
+ && !rMEvt.IsShift())
+ {
+ Point aPos = PixelToLogic( rMEvt.GetPosPixel() );
+ sal_uInt16 aPageId = GetPageId(aPos);
+
+ if (aPageId == 0)
+ {
+ SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher();
+
+ pDispatcher->Execute(SID_INSERTPAGE_QUICK,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
+ }
+ }
+
+ // A single left click with pressed control key on a tab page first
+ // switches to that page before the usual handling (copying with drag
+ // and drop) takes place.
+ else if (rMEvt.IsLeft() && rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsShift())
+ {
+ pDrViewSh->SwitchPage (GetPageId (rMEvt.GetPosPixel()) - 1);
+ }
+
+ // When only the right button is pressed then first process a
+ // synthesized left button click to make the page the current one
+ // whose tab has been clicked. When then the actual right button
+ // click is processed the resulting context menu relates to the
+ // now current page.
+ if (rMEvt.IsRight() && ! rMEvt.IsLeft())
+ {
+ MouseEvent aSyntheticEvent (
+ rMEvt.GetPosPixel(),
+ rMEvt.GetClicks(),
+ rMEvt.GetMode(),
+ MOUSE_LEFT,
+ rMEvt.GetModifier());
+ TabBar::MouseButtonDown(aSyntheticEvent);
+ }
+
+ TabBar::MouseButtonDown(rMEvt);
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void TabControl::DoubleClick()
+{
+ if (GetCurPageId() != 0)
+ {
+ SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher();
+ pDispatcher->Execute( SID_MODIFYPAGE,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD );
+ }
+}
+
+/*************************************************************************
+|*
+|* StartDrag-Request
+|*
+\************************************************************************/
+
+void TabControl::StartDrag( sal_Int8, const Point& )
+{
+ bInternalMove = sal_True;
+
+ // object is delete by reference mechanismn
+ ( new TabControl::TabControlTransferable( *this ) )->StartDrag( this, DND_ACTION_COPYMOVE );
+}
+
+/*************************************************************************
+|*
+|* DragFinished
+|*
+\************************************************************************/
+
+void TabControl::DragFinished( sal_Int8 )
+{
+ bInternalMove = sal_False;
+}
+
+/*************************************************************************
+|*
+|* AcceptDrop-Event
+|*
+\************************************************************************/
+
+sal_Int8 TabControl::AcceptDrop( const AcceptDropEvent& rEvt )
+{
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( rEvt.mbLeaving )
+ EndSwitchPage();
+
+ if( !pDrViewSh->GetDocSh()->IsReadOnly() )
+ {
+ SdDrawDocument* pDoc = pDrViewSh->GetDoc();
+ Point aPos( rEvt.maPosPixel );
+
+ if( bInternalMove )
+ {
+ if( rEvt.mbLeaving || ( pDrViewSh->GetEditMode() == EM_MASTERPAGE ) )
+ HideDropPos();
+ else
+ {
+ ShowDropPos( aPos );
+ nRet = rEvt.mnAction;
+ }
+ }
+ else
+ {
+ HideDropPos();
+
+ sal_Int32 nPageId = GetPageId( aPos ) - 1;
+
+ if( ( nPageId >= 0 ) && pDoc->GetPage( (sal_uInt16)nPageId ) )
+ {
+ nRet = pDrViewSh->AcceptDrop( rEvt, *this, NULL, (sal_uInt16)nPageId, SDRLAYER_NOTFOUND );
+ SwitchPage( aPos );
+ }
+ }
+ }
+
+ return nRet;
+}
+
+/*************************************************************************
+|*
+|* ExecuteDrop-Event
+|*
+\************************************************************************/
+
+sal_Int8 TabControl::ExecuteDrop( const ExecuteDropEvent& rEvt )
+{
+ SdDrawDocument* pDoc = pDrViewSh->GetDoc();
+ Point aPos( rEvt.maPosPixel );
+ sal_Int8 nRet = DND_ACTION_NONE;
+
+ if( bInternalMove )
+ {
+ sal_uInt16 nPageId = ShowDropPos( aPos ) - 1;
+
+ switch (rEvt.mnAction)
+ {
+ case DND_ACTION_MOVE:
+ if( pDrViewSh->IsSwitchPageAllowed() && pDoc->MovePages( nPageId ) )
+ {
+ SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher();
+ pDispatcher->Execute(SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+ }
+ break;
+
+ case DND_ACTION_COPY:
+ {
+ // Copying the selected page to the place that rEvt points
+ // takes place in three steps:
+ // 1. Create a copy of the selected page. This copy will
+ // lie directly behind the selected page.
+ // 2. Move the copy to the desired place.
+ // 3. Select the copy.
+ if (pDrViewSh->IsSwitchPageAllowed())
+ {
+ // 1. Create a copy.
+ sal_uInt16 nPageNumOfCopy = pDoc->DuplicatePage (GetCurPageId() - 1);
+ // 2. Move page. For this first switch to the copy:
+ // MovePages operates on the currently selected page(s).
+ pDrViewSh->SwitchPage (nPageNumOfCopy);
+ // Adapt target page id when necessary, i.e. page copy
+ // has been inserted in front of the target page.
+ sal_uInt16 nPageNum = nPageId;
+ if ((nPageNumOfCopy <= nPageNum) && (nPageNum != (sal_uInt16)-1))
+ nPageNum += 1;
+ if (pDoc->MovePages(nPageNum))
+ {
+ // 3. Switch to the copy that has been moved to its
+ // final destination. Use an asynchron slot call to
+ // be executed after the still pending ones.
+ if (nPageNumOfCopy >= nPageNum || (nPageNum == (sal_uInt16)-1))
+ nPageNum += 1;
+ SetCurPageId (GetPageId(nPageNum));
+ SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher();
+ pDispatcher->Execute(SID_SWITCHPAGE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+ }
+ }
+
+ break;
+ }
+ }
+
+ nRet = rEvt.mnAction;
+ }
+ else
+ {
+ sal_Int32 nPageId = GetPageId( aPos ) - 1;
+
+ if( ( nPageId >= 0 ) && pDoc->GetPage( (sal_uInt16)nPageId ) )
+ {
+ nRet = pDrViewSh->ExecuteDrop( rEvt, *this, NULL, (sal_uInt16)nPageId, SDRLAYER_NOTFOUND );
+ }
+ }
+
+ HideDropPos();
+ EndSwitchPage();
+
+ return nRet;
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void TabControl::Command(const CommandEvent& rCEvt)
+{
+ sal_uInt16 nCmd = rCEvt.GetCommand();
+
+ if ( nCmd == COMMAND_CONTEXTMENU )
+ {
+ sal_Bool bGraphicShell = pDrViewSh->ISA(GraphicViewShell);
+ sal_uInt16 nResId = bGraphicShell ? RID_GRAPHIC_PAGETAB_POPUP :
+ RID_DRAW_PAGETAB_POPUP;
+ SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher();
+ pDispatcher->ExecutePopup( SdResId( nResId ) );
+ }
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+long TabControl::StartRenaming()
+{
+ sal_Bool bOK = sal_False;
+
+ if (pDrViewSh->GetPageKind() == PK_STANDARD)
+ {
+ bOK = sal_True;
+
+ ::sd::View* pView = pDrViewSh->GetView();
+
+ if ( pView->IsTextEdit() )
+ pView->SdrEndTextEdit();
+ }
+
+ return( bOK );
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+long TabControl::AllowRenaming()
+{
+ sal_Bool bOK = sal_True;
+
+ String aNewName( GetEditText() );
+ String aCompareName( GetPageText( GetEditPageId() ) );
+
+ if( aCompareName != aNewName )
+ {
+ // Seite umbenennen
+ if( pDrViewSh->GetDocSh()->CheckPageName( this, aNewName ) )
+ {
+ SetEditText( aNewName );
+ EndRenaming();
+ }
+ else
+ {
+ bOK = sal_False;
+ }
+ }
+ return( bOK );
+}
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void TabControl::EndRenaming()
+{
+ if( !IsEditModeCanceled() )
+ pDrViewSh->RenameSlide( GetEditPageId(), GetEditText() );
+}
+
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+void TabControl::ActivatePage()
+{
+ if ( /*IsInSwitching && */ pDrViewSh->IsSwitchPageAllowed() )
+ {
+ SfxDispatcher* pDispatcher = pDrViewSh->GetViewFrame()->GetDispatcher();
+ pDispatcher->Execute(SID_SWITCHPAGE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+ }
+}
+
+
+/*************************************************************************
+|*
+\************************************************************************/
+
+long TabControl::DeactivatePage()
+{
+ return pDrViewSh->IsSwitchPageAllowed();
+}
+
+
+
+
+void TabControl::SendActivatePageEvent (void)
+{
+ CallEventListeners (VCLEVENT_TABBAR_PAGEACTIVATED,
+ reinterpret_cast<void*>(GetCurPageId()));
+}
+
+
+
+
+void TabControl::SendDeactivatePageEvent (void)
+{
+ CallEventListeners (VCLEVENT_TABBAR_PAGEDEACTIVATED,
+ reinterpret_cast<void*>(GetCurPageId()));
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/unmodpg.cxx b/sd/source/ui/view/unmodpg.cxx
new file mode 100755
index 000000000000..f88799118577
--- /dev/null
+++ b/sd/source/ui/view/unmodpg.cxx
@@ -0,0 +1,247 @@
+/*************************************************************************
+ *
+ * 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"
+
+#ifndef _SVDLAYER
+#include <svx/svdlayer.hxx>
+#endif
+#include <sfx2/dispatch.hxx>
+#include <sfx2/viewfrm.hxx>
+
+
+#include "strings.hrc"
+#include "glob.hxx"
+#include "glob.hrc" // STR_BCKGRND, STR_BCKGRNDOBJ
+#include "app.hrc" // SID_SWITCHPAGE
+
+#include "unmodpg.hxx"
+#include "sdpage.hxx"
+#include "sdresid.hxx"
+#include "drawdoc.hxx"
+
+
+TYPEINIT1(ModifyPageUndoAction, SdUndoAction);
+
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+ModifyPageUndoAction::ModifyPageUndoAction(
+ SdDrawDocument* pTheDoc,
+ SdPage* pThePage,
+ String aTheNewName,
+ AutoLayout eTheNewAutoLayout,
+ sal_Bool bTheNewBckgrndVisible,
+ sal_Bool bTheNewBckgrndObjsVisible)
+: SdUndoAction(pTheDoc)
+{
+ DBG_ASSERT(pThePage, "Undo ohne Seite ???");
+
+ mpPage = pThePage;
+ maNewName = aTheNewName;
+ meNewAutoLayout = eTheNewAutoLayout;
+ mbNewBckgrndVisible = bTheNewBckgrndVisible;
+ mbNewBckgrndObjsVisible = bTheNewBckgrndObjsVisible;
+
+ meOldAutoLayout = mpPage->GetAutoLayout();
+
+ if (!mpPage->IsMasterPage())
+ {
+ maOldName = mpPage->GetName();
+ SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
+ sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
+ sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
+ SetOfByte aVisibleLayers = mpPage->TRG_GetMasterPageVisibleLayers();
+
+ mbOldBckgrndVisible = aVisibleLayers.IsSet(aBckgrnd);
+ mbOldBckgrndObjsVisible = aVisibleLayers.IsSet(aBckgrndObj);
+ }
+
+ maComment = String(SdResId(STR_UNDO_MODIFY_PAGE));
+}
+
+/*************************************************************************
+|*
+|* Undo()
+|*
+\************************************************************************/
+#include <svx/svdviter.hxx>
+#include <svx/svdview.hxx>
+void ModifyPageUndoAction::Undo()
+{
+ // #94637# invalidate Selection, there could be objects deleted in tis UNDO
+ // which are no longer allowed to be selected then.
+ SdrViewIter aIter(mpPage);
+ SdrView* pView = aIter.FirstView();
+
+ while(pView)
+ {
+ if(pView->AreObjectsMarked())
+ pView->UnmarkAll();
+ pView = aIter.NextView();
+ }
+
+ mpPage->SetAutoLayout( meOldAutoLayout );
+
+ if (!mpPage->IsMasterPage())
+ {
+ if (mpPage->GetName() != maOldName)
+ {
+ mpPage->SetName(maOldName);
+
+ if (mpPage->GetPageKind() == PK_STANDARD)
+ {
+ SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
+ pNotesPage->SetName(maOldName);
+ }
+ }
+
+ SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
+ sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
+ sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
+ SetOfByte aVisibleLayers;
+ aVisibleLayers.Set(aBckgrnd, mbOldBckgrndVisible);
+ aVisibleLayers.Set(aBckgrndObj, mbOldBckgrndObjsVisible);
+ mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
+ }
+
+ // Redisplay
+ SfxViewFrame::Current()->GetDispatcher()->Execute(
+ SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+}
+
+/*************************************************************************
+|*
+|* Redo()
+|*
+\************************************************************************/
+
+void ModifyPageUndoAction::Redo()
+{
+ // #94637# invalidate Selection, there could be objects deleted in tis UNDO
+ // which are no longer allowed to be selected then.
+ SdrViewIter aIter(mpPage);
+ SdrView* pView = aIter.FirstView();
+
+ while(pView)
+ {
+ if(pView->AreObjectsMarked())
+ pView->UnmarkAll();
+ pView = aIter.NextView();
+ }
+
+ mpPage->meAutoLayout = meNewAutoLayout;
+
+ if (!mpPage->IsMasterPage())
+ {
+ if (mpPage->GetName() != maNewName)
+ {
+ mpPage->SetName(maNewName);
+
+ if (mpPage->GetPageKind() == PK_STANDARD)
+ {
+ SdPage* pNotesPage = (SdPage*)mpDoc->GetPage(mpPage->GetPageNum() + 1);
+ pNotesPage->SetName(maNewName);
+ }
+ }
+
+ SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
+ sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
+ sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
+ SetOfByte aVisibleLayers;
+ aVisibleLayers.Set(aBckgrnd, mbNewBckgrndVisible);
+ aVisibleLayers.Set(aBckgrndObj, mbNewBckgrndObjsVisible);
+ mpPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
+ }
+
+ // Redisplay
+ SfxViewFrame::Current()->GetDispatcher()->Execute(
+ SID_SWITCHPAGE, SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD );
+}
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+ModifyPageUndoAction::~ModifyPageUndoAction()
+{
+}
+
+/*************************************************************************
+|*
+|* Kommentar liefern
+|*
+\************************************************************************/
+
+String ModifyPageUndoAction::GetComment() const
+{
+ return maComment;
+}
+
+// --------------------------------------------------------------------
+
+RenameLayoutTemplateUndoAction::RenameLayoutTemplateUndoAction( SdDrawDocument* pDocument, const String& rOldLayoutName, const String& rNewLayoutName )
+: SdUndoAction(pDocument)
+, maOldName( rOldLayoutName )
+, maNewName( rNewLayoutName )
+, maComment(SdResId(STR_TITLE_RENAMESLIDE))
+{
+ sal_uInt16 nPos = maOldName.SearchAscii( SD_LT_SEPARATOR );
+ if( nPos != (sal_uInt16)-1 )
+ maOldName.Erase(nPos);
+}
+
+void RenameLayoutTemplateUndoAction::Undo()
+{
+ String aLayoutName( maNewName );
+ aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
+ aLayoutName.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
+
+ mpDoc->RenameLayoutTemplate( aLayoutName, maOldName );
+}
+
+void RenameLayoutTemplateUndoAction::Redo()
+{
+ String aLayoutName( maOldName );
+ aLayoutName.AppendAscii( RTL_CONSTASCII_STRINGPARAM( SD_LT_SEPARATOR ));
+ aLayoutName.Append( String(SdResId(STR_LAYOUT_OUTLINE))) ;
+
+ mpDoc->RenameLayoutTemplate( aLayoutName, maNewName );
+}
+
+String RenameLayoutTemplateUndoAction::GetComment() const
+{
+ return maComment;
+}
+
diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx
new file mode 100755
index 000000000000..b35eb25d45b6
--- /dev/null
+++ b/sd/source/ui/view/viewoverlaymanager.cxx
@@ -0,0 +1,619 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: $
+ * $Revision: $
+ *
+ * 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 "sddll.hxx"
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <sfx2/imagemgr.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <tools/rcid.h>
+
+#include <vcl/help.hxx>
+#include <vcl/imagerepository.hxx>
+#include <vcl/lazydelete.hxx>
+
+#include <svx/sdrpagewindow.hxx>
+#include <svx/sdrpaintwindow.hxx>
+#include <svx/sdr/overlay/overlayanimatedbitmapex.hxx>
+#include <svx/sdr/overlay/overlaybitmapex.hxx>
+#include <svx/sdr/overlay/overlaymanager.hxx>
+#include <svx/svxids.hrc>
+
+#include "view/viewoverlaymanager.hxx"
+
+#include "res_bmp.hrc"
+#include "DrawDocShell.hxx"
+#include "DrawViewShell.hxx"
+#include "DrawController.hxx"
+#include "glob.hrc"
+#include "strings.hrc"
+#include "sdresid.hxx"
+#include "EventMultiplexer.hxx"
+#include "ViewShellManager.hxx"
+#include "helpids.h"
+#include "sdpage.hxx"
+#include "drawdoc.hxx"
+#include "smarttag.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+
+namespace sd {
+
+class ImageButtonHdl;
+
+// --------------------------------------------------------------------
+
+static sal_uInt16 gButtonSlots[] = { SID_INSERT_TABLE, SID_INSERT_DIAGRAM, SID_INSERT_GRAPHIC, SID_INSERT_AVMEDIA };
+static sal_uInt16 gButtonToolTips[] = { STR_INSERT_TABLE, STR_INSERT_CHART, STR_INSERT_PICTURE, STR_INSERT_MOVIE };
+
+// --------------------------------------------------------------------
+
+static BitmapEx loadImageResource( sal_uInt16 nId )
+{
+ SdResId aResId( nId );
+ aResId.SetRT( RSC_BITMAP );
+
+ return BitmapEx( aResId );
+}
+
+// --------------------------------------------------------------------
+
+static BitmapEx* getButtonImage( int index, bool large )
+{
+ static vcl::DeleteOnDeinit< BitmapEx > gSmallButtonImages[BMP_PLACEHOLDER_SMALL_END - BMP_PLACEHOLDER_SMALL_START] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ static vcl::DeleteOnDeinit< BitmapEx > gLargeButtonImages[BMP_PLACEHOLDER_LARGE_END - BMP_PLACEHOLDER_LARGE_START] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
+ if( !gSmallButtonImages[0].get() )
+ {
+ for( sal_uInt16 i = 0; i < (BMP_PLACEHOLDER_SMALL_END-BMP_PLACEHOLDER_SMALL_START); i++ )
+ {
+ gSmallButtonImages[i].set( new BitmapEx( loadImageResource( BMP_PLACEHOLDER_SMALL_START + i ) ) );
+ gLargeButtonImages[i].set( new BitmapEx( loadImageResource( BMP_PLACEHOLDER_LARGE_START + i ) ) );
+ }
+ }
+
+ if( large )
+ {
+ return gLargeButtonImages[index].get();
+ }
+ else
+ {
+ return gSmallButtonImages[index].get();
+ }
+}
+
+// --------------------------------------------------------------------
+
+const sal_uInt32 SMART_TAG_HDL_NUM = SAL_MAX_UINT32;
+
+class ChangePlaceholderTag : public SmartTag
+{
+ friend class ImageButtonHdl;
+public:
+ ChangePlaceholderTag( ViewOverlayManager& rManager, ::sd::View& rView, SdrObject& rPlaceholderObj );
+ virtual ~ChangePlaceholderTag();
+
+ /** returns true if the SmartTag handled the event. */
+ virtual bool MouseButtonDown( const MouseEvent&, SmartHdl& );
+
+ /** returns true if the SmartTag consumes this event. */
+ virtual bool KeyInput( const KeyEvent& rKEvt );
+
+ BitmapEx createOverlayImage( int nHighlight = -1 );
+
+protected:
+ virtual void addCustomHandles( SdrHdlList& rHandlerList );
+ virtual void disposing();
+ virtual void select();
+ virtual void deselect();
+
+private:
+ ViewOverlayManager& mrManager;
+ SdrObjectWeakRef mxPlaceholderObj;
+};
+
+class ImageButtonHdl : public SmartHdl
+{
+public:
+ ImageButtonHdl( const SmartTagReference& xTag, /* sal_uInt16 nSID, const Image& rImage, const Image& rImageMO, */ const Point& rPnt );
+ virtual ~ImageButtonHdl();
+ virtual void CreateB2dIAObject();
+ virtual sal_Bool IsFocusHdl() const;
+ virtual Pointer GetPointer() const;
+ virtual bool isMarkable() const;
+
+ virtual void onMouseEnter(const MouseEvent& rMEvt);
+ virtual void onMouseLeave();
+
+ int getHighlightId() const { return mnHighlightId; }
+
+ void HideTip();
+
+private:
+ rtl::Reference< ChangePlaceholderTag > mxTag;
+
+ int mnHighlightId;
+ Size maImageSize;
+ sal_uLong mnTip;
+};
+
+// --------------------------------------------------------------------
+
+ImageButtonHdl::ImageButtonHdl( const SmartTagReference& xTag /*, sal_uInt16 nSID, const Image& rImage, const Image& rImageMO*/, const Point& rPnt )
+: SmartHdl( xTag, rPnt )
+, mxTag( dynamic_cast< ChangePlaceholderTag* >( xTag.get() ) )
+, mnHighlightId( -1 )
+, maImageSize( 42, 42 )
+, mnTip( 0 )
+{
+}
+
+// --------------------------------------------------------------------
+
+ImageButtonHdl::~ImageButtonHdl()
+{
+ HideTip();
+}
+
+// --------------------------------------------------------------------
+
+void ImageButtonHdl::HideTip()
+{
+ if( mnTip )
+ {
+ Help::HideTip( mnTip );
+ mnTip = 0;
+ }
+}
+
+// --------------------------------------------------------------------
+
+extern ::rtl::OUString ImplRetrieveLabelFromCommand( const Reference< XFrame >& xFrame, const OUString& aCmdURL );
+
+void ImageButtonHdl::onMouseEnter(const MouseEvent& rMEvt)
+{
+ int nHighlightId = 0;
+
+ if( pHdlList && pHdlList->GetView())
+ {
+ OutputDevice* pDev = pHdlList->GetView()->GetFirstOutputDevice();
+ if( pDev == 0 )
+ pDev = Application::GetDefaultDevice();
+
+ Point aMDPos( rMEvt.GetPosPixel() );
+ aMDPos -= pDev->LogicToPixel( GetPos() );
+
+ nHighlightId += aMDPos.X() > maImageSize.Width() ? 1 : 0;
+ nHighlightId += aMDPos.Y() > maImageSize.Height() ? 2 : 0;
+
+ if( mnHighlightId != nHighlightId )
+ {
+ HideTip();
+
+ mnHighlightId = nHighlightId;
+
+ if( pHdlList )
+ {
+ SdResId aResId( gButtonToolTips[mnHighlightId] );
+ aResId.SetRT( RSC_STRING );
+
+ String aHelpText( aResId );
+ Rectangle aScreenRect( pDev->LogicToPixel( GetPos() ), maImageSize );
+ mnTip = Help::ShowTip( static_cast< ::Window* >( pHdlList->GetView()->GetFirstOutputDevice() ), aScreenRect, aHelpText, 0 ) ;
+ }
+ Touch();
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+void ImageButtonHdl::onMouseLeave()
+{
+ mnHighlightId = -1;
+ HideTip();
+ Touch();
+}
+
+// --------------------------------------------------------------------
+
+void ImageButtonHdl::CreateB2dIAObject()
+{
+ // first throw away old one
+ GetRidOfIAObject();
+
+ const Point aTagPos( GetPos() );
+ basegfx::B2DPoint aPosition( aTagPos.X(), aTagPos.Y() );
+
+ BitmapEx aBitmapEx( mxTag->createOverlayImage( mnHighlightId ) ); // maImageMO.GetBitmapEx() : maImage.GetBitmapEx() );
+ maImageSize = aBitmapEx.GetSizePixel();
+ maImageSize.Width() >>= 1;
+ maImageSize.Height() >>= 1;
+
+ if(pHdlList)
+ {
+ SdrMarkView* pView = pHdlList->GetView();
+
+ if(pView && !pView->areMarkHandlesHidden())
+ {
+ SdrPageView* pPageView = pView->GetSdrPageView();
+
+ if(pPageView)
+ {
+ for(sal_uInt32 b = 0; b < pPageView->PageWindowCount(); b++)
+ {
+ const SdrPageWindow& rPageWindow = *pPageView->GetPageWindow(b);
+
+ SdrPaintWindow& rPaintWindow = rPageWindow.GetPaintWindow();
+ if(rPaintWindow.OutputToWindow() && rPageWindow.GetOverlayManager() )
+ {
+ ::sdr::overlay::OverlayObject* pOverlayObject = 0;
+
+ pOverlayObject = new ::sdr::overlay::OverlayBitmapEx( aPosition, aBitmapEx, 0, 0 );
+ rPageWindow.GetOverlayManager()->add(*pOverlayObject);
+ maOverlayGroup.append(*pOverlayObject);
+ }
+ }
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------
+
+sal_Bool ImageButtonHdl::IsFocusHdl() const
+{
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+bool ImageButtonHdl::isMarkable() const
+{
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+Pointer ImageButtonHdl::GetPointer() const
+{
+ return Pointer( POINTER_ARROW );
+}
+
+// ====================================================================
+
+ChangePlaceholderTag::ChangePlaceholderTag( ViewOverlayManager& rManager, ::sd::View& rView, SdrObject& rPlaceholderObj )
+: SmartTag( rView )
+, mrManager( rManager )
+, mxPlaceholderObj( &rPlaceholderObj )
+{
+}
+
+// --------------------------------------------------------------------
+
+ChangePlaceholderTag::~ChangePlaceholderTag()
+{
+}
+
+// --------------------------------------------------------------------
+
+/** returns true if the ChangePlaceholderTag handled the event. */
+bool ChangePlaceholderTag::MouseButtonDown( const MouseEvent& /*rMEvt*/, SmartHdl& rHdl )
+{
+ int nHighlightId = static_cast< ImageButtonHdl& >(rHdl).getHighlightId();
+ if( nHighlightId >= 0 )
+ {
+ sal_uInt16 nSID = gButtonSlots[nHighlightId];
+
+ if( mxPlaceholderObj.get() )
+ {
+ // mark placeholder if it is not currently marked (or if also others are marked)
+ if( !mrView.IsObjMarked( mxPlaceholderObj.get() ) || (mrView.GetMarkedObjectList().GetMarkCount() != 1) )
+ {
+ SdrPageView* pPV = mrView.GetSdrPageView();
+ mrView.UnmarkAllObj(pPV );
+ mrView.MarkObj(mxPlaceholderObj.get(), pPV, sal_False);
+ }
+ }
+
+ mrView.GetViewShell()->GetViewFrame()->GetDispatcher()->Execute( nSID, SFX_CALLMODE_ASYNCHRON);
+ }
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+/** returns true if the SmartTag consumes this event. */
+bool ChangePlaceholderTag::KeyInput( const KeyEvent& rKEvt )
+{
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
+ switch( nCode )
+ {
+ case KEY_DOWN:
+ case KEY_UP:
+ case KEY_LEFT:
+ case KEY_RIGHT:
+ case KEY_ESCAPE:
+ case KEY_TAB:
+ case KEY_RETURN:
+ case KEY_SPACE:
+ default:
+ return false;
+ }
+}
+
+// --------------------------------------------------------------------
+
+BitmapEx ChangePlaceholderTag::createOverlayImage( int nHighlight )
+{
+ BitmapEx aRet;
+ if( mxPlaceholderObj.is() )
+ {
+ SdrObject* pPlaceholder = mxPlaceholderObj.get();
+ SmartTagReference xThis( this );
+ const Rectangle& rSnapRect = pPlaceholder->GetSnapRect();
+ const Point aPoint;
+
+ OutputDevice* pDev = mrView.GetFirstOutputDevice();
+ if( pDev == 0 )
+ pDev = Application::GetDefaultDevice();
+
+ Size aShapeSizePix = pDev->LogicToPixel(rSnapRect.GetSize());
+ long nShapeSizePix = std::min(aShapeSizePix.Width(),aShapeSizePix.Height());
+
+ bool bLarge = nShapeSizePix > 250;
+
+ Size aSize( getButtonImage( 0, bLarge )->GetSizePixel() );
+
+ aRet.SetSizePixel( Size( aSize.Width() << 1, aSize.Height() << 1 ) );
+
+ const Rectangle aRectSrc( Point( 0, 0 ), aSize );
+
+ aRet = *(getButtonImage((nHighlight == 0) ? 4 : 0, bLarge));
+ aRet.Expand( aSize.Width(), aSize.Height(), NULL, sal_True );
+
+ aRet.CopyPixel( Rectangle( Point( aSize.Width(), 0 ), aSize ), aRectSrc, getButtonImage((nHighlight == 1) ? 5 : 1, bLarge) );
+ aRet.CopyPixel( Rectangle( Point( 0, aSize.Height() ), aSize ), aRectSrc, getButtonImage((nHighlight == 2) ? 6 : 2, bLarge) );
+ aRet.CopyPixel( Rectangle( Point( aSize.Width(), aSize.Height() ), aSize ), aRectSrc, getButtonImage((nHighlight == 3) ? 7 : 3, bLarge) );
+ }
+
+ return aRet;
+}
+
+void ChangePlaceholderTag::addCustomHandles( SdrHdlList& rHandlerList )
+{
+ if( mxPlaceholderObj.is() )
+ {
+ SdrObject* pPlaceholder = mxPlaceholderObj.get();
+ SmartTagReference xThis( this );
+ const Rectangle& rSnapRect = pPlaceholder->GetSnapRect();
+ const Point aPoint;
+
+ OutputDevice* pDev = mrView.GetFirstOutputDevice();
+ if( pDev == 0 )
+ pDev = Application::GetDefaultDevice();
+
+ Size aShapeSizePix = pDev->LogicToPixel(rSnapRect.GetSize());
+ long nShapeSizePix = std::min(aShapeSizePix.Width(),aShapeSizePix.Height());
+ if( 50 > nShapeSizePix )
+ return;
+
+ bool bLarge = nShapeSizePix > 250;
+
+ Size aButtonSize( pDev->PixelToLogic( getButtonImage(0, bLarge )->GetSizePixel()) );
+
+ const int nColumns = 2;
+ const int nRows = 2;
+
+ long all_width = nColumns * aButtonSize.Width();
+ long all_height = nRows * aButtonSize.Height();
+
+ Point aPos( rSnapRect.Center() );
+ aPos.X() -= all_width >> 1;
+ aPos.Y() -= all_height >> 1;
+
+ ImageButtonHdl* pHdl = new ImageButtonHdl( xThis, aPoint );
+ pHdl->SetObjHdlNum( SMART_TAG_HDL_NUM );
+ pHdl->SetPageView( mrView.GetSdrPageView() );
+
+ pHdl->SetPos( aPos );
+
+ rHandlerList.AddHdl( pHdl );
+ }
+}
+
+// --------------------------------------------------------------------
+
+void ChangePlaceholderTag::disposing()
+{
+ SmartTag::disposing();
+}
+
+// --------------------------------------------------------------------
+
+void ChangePlaceholderTag::select()
+{
+ SmartTag::select();
+}
+
+// --------------------------------------------------------------------
+
+void ChangePlaceholderTag::deselect()
+{
+ SmartTag::deselect();
+}
+
+// --------------------------------------------------------------------
+
+ViewOverlayManager::ViewOverlayManager( ViewShellBase& rViewShellBase )
+: mrBase( rViewShellBase )
+, mnUpdateTagsEvent( 0 )
+{
+ Link aLink( LINK(this,ViewOverlayManager,EventMultiplexerListener) );
+ mrBase.GetEventMultiplexer()->AddEventListener(aLink, tools::EventMultiplexerEvent::EID_CURRENT_PAGE
+ | tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
+ | tools::EventMultiplexerEvent::EID_VIEW_ADDED
+ | tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT
+ | tools::EventMultiplexerEvent::EID_END_TEXT_EDIT );
+
+ StartListening( *mrBase.GetDocShell() );
+}
+
+// --------------------------------------------------------------------
+
+ViewOverlayManager::~ViewOverlayManager()
+{
+ Link aLink( LINK(this,ViewOverlayManager,EventMultiplexerListener) );
+ mrBase.GetEventMultiplexer()->RemoveEventListener( aLink );
+
+ if( mnUpdateTagsEvent )
+ {
+ Application::RemoveUserEvent( mnUpdateTagsEvent );
+ mnUpdateTagsEvent = 0;
+ }
+
+ DisposeTags();
+}
+
+// --------------------------------------------------------------------
+
+void ViewOverlayManager::Notify(SfxBroadcaster&, const SfxHint& rHint)
+{
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if (pSimpleHint != NULL)
+ {
+ if (pSimpleHint->GetId() == SFX_HINT_DOCCHANGED)
+ {
+ UpdateTags();
+ }
+ }
+}
+
+void ViewOverlayManager::onZoomChanged()
+{
+ if( !maTagVector.empty() )
+ {
+ UpdateTags();
+ }
+}
+
+void ViewOverlayManager::UpdateTags()
+{
+ if( !mnUpdateTagsEvent )
+ mnUpdateTagsEvent = Application::PostUserEvent( LINK( this, ViewOverlayManager, UpdateTagsHdl ) );
+}
+
+IMPL_LINK(ViewOverlayManager,UpdateTagsHdl, void *, EMPTYARG)
+{
+ OSL_TRACE("ViewOverlayManager::UpdateTagsHdl");
+
+ mnUpdateTagsEvent = 0;
+ bool bChanges = DisposeTags();
+ bChanges |= CreateTags();
+
+ if( bChanges && mrBase.GetDrawView() )
+ static_cast< ::sd::View* >( mrBase.GetDrawView() )->updateHandles();
+ return 0;
+}
+
+bool ViewOverlayManager::CreateTags()
+{
+ bool bChanges = false;
+
+ SdPage* pPage = mrBase.GetMainViewShell()->getCurrentPage();
+
+ if( pPage && !pPage->IsMasterPage() && (pPage->GetPageKind() == PK_STANDARD) )
+ {
+ const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList();
+
+ for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); iter++ )
+ {
+ if( (*iter)->IsEmptyPresObj() && ((*iter)->GetObjIdentifier() == OBJ_OUTLINETEXT) && (mrBase.GetDrawView()->GetTextEditObject() != (*iter)) )
+ {
+ rtl::Reference< SmartTag > xTag( new ChangePlaceholderTag( *this, *mrBase.GetMainViewShell()->GetView(), *(*iter) ) );
+ maTagVector.push_back(xTag);
+ bChanges = true;
+ }
+ }
+ }
+
+ return bChanges;
+}
+
+// --------------------------------------------------------------------
+
+bool ViewOverlayManager::DisposeTags()
+{
+ if( !maTagVector.empty() )
+ {
+ ViewTagVector vec;
+ vec.swap( maTagVector );
+
+ ViewTagVector::iterator iter = vec.begin();
+ do
+ {
+ (*iter++)->Dispose();
+ }
+ while( iter != vec.end() );
+ return true;
+ }
+
+ return false;
+}
+
+// --------------------------------------------------------------------
+
+IMPL_LINK(ViewOverlayManager,EventMultiplexerListener,
+ tools::EventMultiplexerEvent*,pEvent)
+{
+ switch (pEvent->meEventId)
+ {
+ case tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
+ case tools::EventMultiplexerEvent::EID_VIEW_ADDED:
+ case tools::EventMultiplexerEvent::EID_BEGIN_TEXT_EDIT:
+ case tools::EventMultiplexerEvent::EID_END_TEXT_EDIT:
+ case tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
+ UpdateTags();
+ break;
+ }
+ return 0;
+}
+
+}
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
new file mode 100755
index 000000000000..637e3ac1793d
--- /dev/null
+++ b/sd/source/ui/view/viewshe2.cxx
@@ -0,0 +1,1213 @@
+/*************************************************************************
+ *
+ * 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 <com/sun/star/embed/NoVisualAreaSizeException.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
+#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
+
+#include "ViewShell.hxx"
+#include "ViewShellHint.hxx"
+
+#include "ViewShellImplementation.hxx"
+#include "FactoryIds.hxx"
+
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#ifndef _SCRBAR_HXX //autogen
+#include <vcl/scrbar.hxx>
+#endif
+#include <svx/svdpagv.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/app.hxx>
+#include <svx/ruler.hxx>
+#include <editeng/outliner.hxx>
+#include <svtools/ehdl.hxx>
+#include <svx/svdoole2.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svx/fmshell.hxx>
+#include <sfx2/dispatch.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <unotools/moduleoptions.hxx>
+#ifndef _SVX_DIALOGS_HRC
+#include <svx/dialogs.hrc>
+#endif
+#include <sot/clsids.hxx>
+
+#include "misc.hxx"
+#include "strings.hrc"
+#include "app.hrc"
+#include "unokywds.hxx"
+
+#include "sdundogr.hxx"
+#include "FrameView.hxx"
+#include "undopage.hxx"
+#include "sdresid.hxx"
+#include "drawdoc.hxx"
+#include "View.hxx"
+#include "fupoor.hxx"
+#include "Client.hxx"
+#include "DrawDocShell.hxx"
+#include "fusearch.hxx"
+#include "slideshow.hxx"
+#include "sdpage.hxx"
+#include "DrawViewShell.hxx"
+#include "ViewShellBase.hxx"
+
+#include "Window.hxx"
+
+#include <sfx2/viewfrm.hxx>
+#include <svtools/soerr.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#ifdef _MSC_VER
+#pragma optimize ( "", off )
+#endif
+
+using namespace com::sun::star;
+
+const String aEmptyStr;
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Scrollbar-Update: Thumbpos und VisibleSize anpassen
+|*
+\************************************************************************/
+
+void ViewShell::UpdateScrollBars()
+{
+ if (mpHorizontalScrollBar.get() != NULL)
+ {
+ long nW = (long)(mpContentWindow->GetVisibleWidth() * 32000);
+ long nX = (long)(mpContentWindow->GetVisibleX() * 32000);
+ mpHorizontalScrollBar->SetVisibleSize(nW);
+ mpHorizontalScrollBar->SetThumbPos(nX);
+ nW = 32000 - nW;
+ long nLine = (long) (mpContentWindow->GetScrlLineWidth() * nW);
+ long nPage = (long) (mpContentWindow->GetScrlPageWidth() * nW);
+ mpHorizontalScrollBar->SetLineSize(nLine);
+ mpHorizontalScrollBar->SetPageSize(nPage);
+ }
+
+ if (mpVerticalScrollBar.get() != NULL)
+ {
+ long nH = (long)(mpContentWindow->GetVisibleHeight() * 32000);
+ long nY = (long)(mpContentWindow->GetVisibleY() * 32000);
+
+ if(IsPageFlipMode()) // ie in zoom mode where no panning
+ {
+ SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
+ sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) / 2;
+ sal_uInt16 nTotalPages = GetDoc()->GetSdPageCount(pPage->GetPageKind());
+ mpVerticalScrollBar->SetRange(Range(0,256*nTotalPages));
+ mpVerticalScrollBar->SetVisibleSize(256);
+ mpVerticalScrollBar->SetThumbPos(256*nCurPage);
+ mpVerticalScrollBar->SetLineSize(256);
+ mpVerticalScrollBar->SetPageSize(256);
+ }
+ else
+ {
+ mpVerticalScrollBar->SetRange(Range(0,32000));
+ mpVerticalScrollBar->SetVisibleSize(nH);
+ mpVerticalScrollBar->SetThumbPos(nY);
+ nH = 32000 - nH;
+ long nLine = (long) (mpContentWindow->GetScrlLineHeight() * nH);
+ long nPage = (long) (mpContentWindow->GetScrlPageHeight() * nH);
+ mpVerticalScrollBar->SetLineSize(nLine);
+ mpVerticalScrollBar->SetPageSize(nPage);
+ }
+ }
+
+ if (mbHasRulers)
+ {
+ UpdateHRuler();
+ UpdateVRuler();
+ }
+
+}
+/*************************************************************************
+|*
+|* Handling fuer horizontale Scrollbars
+|*
+\************************************************************************/
+
+IMPL_LINK_INLINE_START(ViewShell, HScrollHdl, ScrollBar *, pHScroll )
+{
+ return VirtHScrollHdl(pHScroll);
+}
+IMPL_LINK_INLINE_END(ViewShell, HScrollHdl, ScrollBar *, pHScroll )
+
+/*************************************************************************
+|*
+|* virtueller Scroll-Handler fuer horizontale Scrollbars
+|*
+\************************************************************************/
+
+long ViewShell::VirtHScrollHdl(ScrollBar* pHScroll)
+{
+ long nDelta = pHScroll->GetDelta();
+
+ if (nDelta != 0)
+ {
+ double fX = (double) pHScroll->GetThumbPos() / pHScroll->GetRange().Len();
+
+ // alle Fenster der Spalte scrollen
+ ::sd::View* pView = GetView();
+ OutlinerView* pOLV = NULL;
+
+ if (pView)
+ pOLV = pView->GetTextEditOutlinerView();
+
+ if (pOLV)
+ pOLV->HideCursor();
+
+ mpContentWindow->SetVisibleXY(fX, -1);
+
+ Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
+ Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
+ aVisArea.SetPos(aVisAreaPos);
+ GetDocSh()->SetVisArea(aVisArea);
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ VisAreaChanged(aVisAreaWin);
+
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+
+ if (pOLV)
+ pOLV->ShowCursor();
+
+ if (mbHasRulers)
+ UpdateHRuler();
+
+ }
+
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Handling fuer vertikale Scrollbars
+|*
+\************************************************************************/
+
+IMPL_LINK_INLINE_START(ViewShell, VScrollHdl, ScrollBar *, pVScroll )
+{
+ return VirtVScrollHdl(pVScroll);
+}
+IMPL_LINK_INLINE_END(ViewShell, VScrollHdl, ScrollBar *, pVScroll )
+
+/*************************************************************************
+|*
+|* Handling fuer vertikale Scrollbars
+|*
+\************************************************************************/
+
+long ViewShell::VirtVScrollHdl(ScrollBar* pVScroll)
+{
+ if(IsPageFlipMode())
+ {
+ SdPage* pPage = static_cast<DrawViewShell*>(this)->GetActualPage();
+ sal_uInt16 nCurPage = (pPage->GetPageNum() - 1) >> 1;
+ sal_uInt16 nNewPage = (sal_uInt16)pVScroll->GetThumbPos()/256;
+ if( nCurPage != nNewPage )
+ static_cast<DrawViewShell*>(this)->SwitchPage(nNewPage);
+ }
+ else //panning mode
+ {
+ double fY = (double) pVScroll->GetThumbPos() / pVScroll->GetRange().Len();
+
+ ::sd::View* pView = GetView();
+ OutlinerView* pOLV = NULL;
+
+ if (pView)
+ pOLV = pView->GetTextEditOutlinerView();
+
+ if (pOLV)
+ pOLV->HideCursor();
+
+ mpContentWindow->SetVisibleXY(-1, fY);
+
+ Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
+ Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
+ aVisArea.SetPos(aVisAreaPos);
+ GetDocSh()->SetVisArea(aVisArea);
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ VisAreaChanged(aVisAreaWin);
+
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+
+ if (pOLV)
+ pOLV->ShowCursor();
+
+ if (mbHasRulers)
+ UpdateVRuler();
+
+ }
+
+ return 0;
+}
+
+SvxRuler* ViewShell::CreateHRuler(::sd::Window* , sal_Bool )
+{
+ return NULL;
+}
+
+SvxRuler* ViewShell::CreateVRuler(::sd::Window* )
+{
+ return NULL;
+}
+
+void ViewShell::UpdateHRuler()
+{
+}
+
+void ViewShell::UpdateVRuler()
+{
+}
+
+long ViewShell::GetHCtrlWidth()
+{
+ return 0;
+}
+
+/*************************************************************************
+|*
+|* Eine bestimmte Anzahl von Zeilen scrollen (wird beim automatischen
+|* Scrollen (Zeichen/Draggen) verwendet)
+|*
+\************************************************************************/
+
+void ViewShell::ScrollLines(long nLinesX, long nLinesY)
+{
+ if ( nLinesX )
+ {
+ nLinesX *= mpHorizontalScrollBar->GetLineSize();
+ }
+ if ( nLinesY )
+ {
+ nLinesY *= mpVerticalScrollBar->GetLineSize();
+ }
+
+ Scroll(nLinesX, nLinesY);
+}
+
+/*************************************************************************
+|*
+|* Window um nScrollX, nScrollY scrollen
+|*
+\************************************************************************/
+
+void ViewShell::Scroll(long nScrollX, long nScrollY)
+{
+ if (nScrollX)
+ {
+ long nNewThumb = mpHorizontalScrollBar->GetThumbPos() + nScrollX;
+ mpHorizontalScrollBar->SetThumbPos(nNewThumb);
+ }
+ if (nScrollY)
+ {
+ long nNewThumb = mpVerticalScrollBar->GetThumbPos() + nScrollY;
+ mpVerticalScrollBar->SetThumbPos(nNewThumb);
+ }
+ double fX = (double) mpHorizontalScrollBar->GetThumbPos() /
+ mpHorizontalScrollBar->GetRange().Len();
+ double fY = (double) mpVerticalScrollBar->GetThumbPos() /
+ mpVerticalScrollBar->GetRange().Len();
+
+ GetActiveWindow()->SetVisibleXY(fX, fY);
+
+ Rectangle aVisArea = GetDocSh()->GetVisArea(ASPECT_CONTENT);
+ Point aVisAreaPos = GetActiveWindow()->PixelToLogic( Point(0,0) );
+ aVisArea.SetPos(aVisAreaPos);
+ GetDocSh()->SetVisArea(aVisArea);
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ VisAreaChanged(aVisAreaWin);
+
+ ::sd::View* pView = GetView();
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+
+ if (mbHasRulers)
+ {
+ UpdateHRuler();
+ UpdateVRuler();
+ }
+}
+
+/*************************************************************************
+|*
+|* Den Zoomfaktor fuer alle Split-Windows setzen
+|*
+\************************************************************************/
+
+void ViewShell::SetZoom(long nZoom)
+{
+ Fraction aUIScale(nZoom, 100);
+ aUIScale *= GetDoc()->GetUIScale();
+
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->SetZoom(aUIScale);
+
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->SetZoom(aUIScale);
+
+ if (mpContentWindow.get() != NULL)
+ {
+ mpContentWindow->SetZoomIntegral(nZoom);
+
+ // #i74769# Here is a 2nd way (besides Window::Scroll) to set the visible prt
+ // of the window. It needs - like Scroll(SCROLL_CHILDREN) does - also to move
+ // the child windows. I am trying INVALIDATE_CHILDREN here which makes things better,
+ // but does not solve the problem completely. Neet to ask PL.
+ mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
+ }
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ VisAreaChanged(aVisAreaWin);
+
+ ::sd::View* pView = GetView();
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+
+ UpdateScrollBars();
+}
+
+/*************************************************************************
+|*
+|* Zoomrechteck fuer aktives Fenster einstellen und alle Split-Windows
+|* auf den gleichen Zoomfaktor setzen
+|*
+\************************************************************************/
+
+void ViewShell::SetZoomRect(const Rectangle& rZoomRect)
+{
+ long nZoom = GetActiveWindow()->SetZoomRect(rZoomRect);
+ Fraction aUIScale(nZoom, 100);
+ aUIScale *= GetDoc()->GetUIScale();
+
+ Point aPos = GetActiveWindow()->GetWinViewPos();
+
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->SetZoom(aUIScale);
+
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->SetZoom(aUIScale);
+
+ if (mpContentWindow.get() != NULL)
+ {
+ Point aNewPos = mpContentWindow->GetWinViewPos();
+ aNewPos.X() = aPos.X();
+ aNewPos.Y() = aPos.Y();
+ mpContentWindow->SetZoomIntegral(nZoom);
+ mpContentWindow->SetWinViewPos(aNewPos);
+ mpContentWindow->UpdateMapOrigin();
+
+ // #i74769# see above
+ mpContentWindow->Invalidate(INVALIDATE_CHILDREN);
+ }
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ VisAreaChanged(aVisAreaWin);
+
+ ::sd::View* pView = GetView();
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+
+ UpdateScrollBars();
+}
+
+/*************************************************************************
+|*
+|* Abbildungsparameter fuer alle Split-Windows initialisieren
+|*
+\************************************************************************/
+
+void ViewShell::InitWindows(const Point& rViewOrigin, const Size& rViewSize,
+ const Point& rWinPos, sal_Bool bUpdate)
+{
+ if (mpContentWindow.get() != NULL)
+ {
+ mpContentWindow->SetViewOrigin(rViewOrigin);
+ mpContentWindow->SetViewSize(rViewSize);
+ mpContentWindow->SetWinViewPos(rWinPos);
+
+ if ( bUpdate )
+ {
+ mpContentWindow->UpdateMapOrigin();
+ mpContentWindow->Invalidate();
+ }
+ }
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ VisAreaChanged(aVisAreaWin);
+
+ ::sd::View* pView = GetView();
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+}
+
+/*************************************************************************
+|*
+|* Alle Split-Windows unter dem uebergebenen Rechteck invalidieren
+|*
+\************************************************************************/
+
+void ViewShell::InvalidateWindows()
+{
+ if (mpContentWindow.get() != NULL)
+ mpContentWindow->Invalidate();
+}
+
+
+/*************************************************************************
+|*
+|* Auf allen Split-Windows ein Markierungsrechteck mit dem
+|* uebergebenen Pen zeichnen
+|*
+\************************************************************************/
+
+void ViewShell::DrawMarkRect(const Rectangle& rRect) const
+{
+ if (mpContentWindow.get() != NULL)
+ {
+ mpContentWindow->InvertTracking(rRect, SHOWTRACK_OBJECT | SHOWTRACK_WINDOW);
+ }
+}
+
+/*************************************************************************
+|*
+|* Groesse und Raender aller Seiten setzen
+|*
+\************************************************************************/
+
+void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize,
+ long nLeft, long nRight,
+ long nUpper, long nLower, sal_Bool bScaleAll,
+ Orientation eOrientation, sal_uInt16 nPaperBin,
+ sal_Bool bBackgroundFullSize)
+{
+ SdPage* pPage = 0;
+ SdUndoGroup* pUndoGroup = NULL;
+ pUndoGroup = new SdUndoGroup(GetDoc());
+ String aString(SdResId(STR_UNDO_CHANGE_PAGEFORMAT));
+ pUndoGroup->SetComment(aString);
+ SfxViewShell* pViewShell = GetViewShell();
+ OSL_ASSERT (pViewShell!=NULL);
+
+ sal_uInt16 i, nPageCnt = GetDoc()->GetMasterSdPageCount(ePageKind);
+
+ Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_START));
+
+ for (i = 0; i < nPageCnt; i++)
+ {
+ /**********************************************************************
+ * Erst alle MasterPages bearbeiten
+ **********************************************************************/
+ pPage = GetDoc()->GetMasterSdPage(i, ePageKind);
+
+ SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage,
+ pPage->GetSize(),
+ pPage->GetLftBorder(), pPage->GetRgtBorder(),
+ pPage->GetUppBorder(), pPage->GetLwrBorder(),
+ pPage->IsScaleObjects(),
+ pPage->GetOrientation(),
+ pPage->GetPaperBin(),
+ pPage->IsBackgroundFullSize(),
+ rNewSize,
+ nLeft, nRight,
+ nUpper, nLower,
+ bScaleAll,
+ eOrientation,
+ nPaperBin,
+ bBackgroundFullSize);
+ pUndoGroup->AddAction(pUndo);
+
+ if (rNewSize.Width() > 0 ||
+ nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0)
+ {
+ Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower);
+ pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll);
+
+ if (rNewSize.Width() > 0)
+ pPage->SetSize(rNewSize);
+ }
+
+ if( nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 )
+ {
+ pPage->SetBorder(nLeft, nUpper, nRight, nLower);
+ }
+
+ pPage->SetOrientation(eOrientation);
+ pPage->SetPaperBin( nPaperBin );
+ pPage->SetBackgroundFullSize( bBackgroundFullSize );
+
+ if ( ePageKind == PK_STANDARD )
+ GetDoc()->GetMasterSdPage(i, PK_NOTES)->CreateTitleAndLayout();
+
+ pPage->CreateTitleAndLayout();
+ }
+
+ nPageCnt = GetDoc()->GetSdPageCount(ePageKind);
+
+ for (i = 0; i < nPageCnt; i++)
+ {
+ /**********************************************************************
+ * Danach alle Pages bearbeiten
+ **********************************************************************/
+ pPage = GetDoc()->GetSdPage(i, ePageKind);
+
+ SdUndoAction* pUndo = new SdPageFormatUndoAction(GetDoc(), pPage,
+ pPage->GetSize(),
+ pPage->GetLftBorder(), pPage->GetRgtBorder(),
+ pPage->GetUppBorder(), pPage->GetLwrBorder(),
+ pPage->IsScaleObjects(),
+ pPage->GetOrientation(),
+ pPage->GetPaperBin(),
+ pPage->IsBackgroundFullSize(),
+ rNewSize,
+ nLeft, nRight,
+ nUpper, nLower,
+ bScaleAll,
+ eOrientation,
+ nPaperBin,
+ bBackgroundFullSize);
+ pUndoGroup->AddAction(pUndo);
+
+ if (rNewSize.Width() > 0 ||
+ nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0)
+ {
+ Rectangle aNewBorderRect(nLeft, nUpper, nRight, nLower);
+ pPage->ScaleObjects(rNewSize, aNewBorderRect, bScaleAll);
+
+ if (rNewSize.Width() > 0)
+ pPage->SetSize(rNewSize);
+ }
+
+ if( nLeft >= 0 || nRight >= 0 || nUpper >= 0 || nLower >= 0 )
+ {
+ pPage->SetBorder(nLeft, nUpper, nRight, nLower);
+ }
+
+ pPage->SetOrientation(eOrientation);
+ pPage->SetPaperBin( nPaperBin );
+ pPage->SetBackgroundFullSize( bBackgroundFullSize );
+
+ if ( ePageKind == PK_STANDARD )
+ {
+ SdPage* pNotesPage = GetDoc()->GetSdPage(i, PK_NOTES);
+ pNotesPage->SetAutoLayout( pNotesPage->GetAutoLayout() );
+ }
+
+ pPage->SetAutoLayout( pPage->GetAutoLayout() );
+ }
+
+ // Handoutseite an neues Format der Standardseiten anpassen
+ if( (ePageKind == PK_STANDARD) || (ePageKind == PK_HANDOUT) )
+ GetDoc()->GetSdPage(0, PK_HANDOUT)->CreateTitleAndLayout(sal_True);
+
+ // Undo Gruppe dem Undo Manager uebergeben
+ pViewShell->GetViewFrame()->GetObjectShell()
+ ->GetUndoManager()->AddUndoAction(pUndoGroup);
+
+ long nWidth = pPage->GetSize().Width();
+ long nHeight = pPage->GetSize().Height();
+
+ Point aPageOrg = Point(nWidth, nHeight / 2);
+ Size aViewSize = Size(nWidth * 3, nHeight * 2);
+
+ InitWindows(aPageOrg, aViewSize, Point(-1, -1), sal_True);
+
+ Point aVisAreaPos;
+
+ if ( GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED )
+ {
+ aVisAreaPos = GetDocSh()->GetVisArea(ASPECT_CONTENT).TopLeft();
+ }
+
+ ::sd::View* pView = GetView();
+ if (pView)
+ {
+ pView->SetWorkArea(Rectangle(Point() - aVisAreaPos - aPageOrg, aViewSize));
+ }
+
+ UpdateScrollBars();
+
+ Point aNewOrigin(pPage->GetLftBorder(), pPage->GetUppBorder());
+
+ if (pView)
+ {
+ pView->GetSdrPageView()->SetPageOrigin(aNewOrigin);
+ }
+
+ pViewShell->GetViewFrame()->GetBindings().Invalidate(SID_RULER_NULL_OFFSET);
+
+ // auf (neue) Seitengroesse zoomen
+ pViewShell->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_PAGE,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+
+ Broadcast (ViewShellHint(ViewShellHint::HINT_PAGE_RESIZE_END));
+}
+
+/*************************************************************************
+|*
+|* Zoom-Faktor fuer InPlace einstellen
+|*
+\************************************************************************/
+
+void ViewShell::SetZoomFactor(const Fraction& rZoomX, const Fraction&)
+{
+ long nZoom = (long)((double) rZoomX * 100);
+ SetZoom(nZoom);
+}
+
+
+/*************************************************************************
+|*
+|* Aktives Fenster setzen
+|*
+\************************************************************************/
+
+void ViewShell::SetActiveWindow (::sd::Window* pWin)
+{
+ SfxViewShell* pViewShell = GetViewShell();
+ OSL_ASSERT (pViewShell!=NULL);
+
+ if (pViewShell->GetWindow() != pWin)
+ {
+ // #i31551# was wrong, it may have been a problem with the repaint at that time.
+ // For transparent form controls, it is necessary to have that flag set, all apps
+ // do set it. Enabling again.
+ if (pWin)
+ {
+ pWin->EnableChildTransparentMode();
+ }
+ }
+
+ if (mpActiveWindow != pWin)
+ mpActiveWindow = pWin;
+
+ // The rest of this function is not guarded anymore against calling this
+ // method with an already active window because the functions may still
+ // point to the old window when the new one has already been assigned to
+ // pWindow elsewhere.
+ ::sd::View* pView = GetView();
+ if (pView)
+ {
+ pView->SetActualWin(pWin);
+ }
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->SetWindow(pWin);
+ }
+}
+
+
+
+/*************************************************************************
+|*
+|* RequestHelp event
+|*
+\************************************************************************/
+
+sal_Bool ViewShell::RequestHelp(const HelpEvent& rHEvt, ::sd::Window*)
+{
+ sal_Bool bReturn = sal_False;
+
+ if (rHEvt.GetMode())
+ {
+ if( GetView() )
+ bReturn = GetView()->getSmartTags().RequestHelp(rHEvt);
+
+ if(!bReturn && HasCurrentFunction())
+ {
+ bReturn = GetCurrentFunction()->RequestHelp(rHEvt);
+ }
+ }
+
+ return(bReturn);
+}
+
+
+
+
+FrameView* ViewShell::GetFrameView (void)
+{
+ return mpFrameView;
+}
+
+
+
+
+void ViewShell::SetFrameView (FrameView* pNewFrameView)
+{
+ mpFrameView = pNewFrameView;
+ ReadFrameViewData (mpFrameView);
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Read FrameViews data and set actual views data
+|*
+\************************************************************************/
+
+void ViewShell::ReadFrameViewData(FrameView*)
+{
+}
+
+
+
+/*************************************************************************
+|*
+|* Write actual views data to FrameView
+|*
+\************************************************************************/
+
+void ViewShell::WriteFrameViewData()
+{
+}
+
+/*************************************************************************
+|*
+|* OLE-Object aktivieren
+|*
+\************************************************************************/
+
+sal_Bool ViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb)
+{
+ ErrCode aErrCode = 0;
+
+ SfxErrorContext aEC(ERRCTX_SO_DOVERB, GetActiveWindow(), RID_SO_ERRCTX);
+ sal_Bool bAbort = sal_False;
+ GetDocSh()->SetWaitCursor( sal_True );
+ SfxViewShell* pViewShell = GetViewShell();
+ OSL_ASSERT (pViewShell!=NULL);
+ bool bChangeDefaultsForChart = false;
+
+ uno::Reference < embed::XEmbeddedObject > xObj = pObj->GetObjRef();
+ if ( !xObj.is() )
+ {
+ /**********************************************************
+ * Leeres OLE-Objekt mit OLE-Objekt versehen
+ **********************************************************/
+ String aName = pObj->GetProgName();
+ ::rtl::OUString aObjName;
+ SvGlobalName aClass;
+
+ if( aName.EqualsAscii( "StarChart" ) || aName.EqualsAscii("StarOrg") )
+ {
+ if( SvtModuleOptions().IsChart() )
+ {
+ aClass = SvGlobalName( SO3_SCH_CLASSID );
+ bChangeDefaultsForChart = true;
+ }
+ }
+ else if( aName.EqualsAscii( "StarCalc" ))
+ {
+ if( SvtModuleOptions().IsCalc() )
+ aClass = SvGlobalName( SO3_SC_CLASSID );
+ }
+ else if( aName.EqualsAscii( "StarMath" ))
+ {
+ if( SvtModuleOptions().IsMath() )
+ aClass = SvGlobalName( SO3_SM_CLASSID );
+ }
+
+ if ( aClass != SvGlobalName() )
+ xObj = GetDocSh()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClass.GetByteSequence(), aObjName );
+
+ if( !xObj.is() )
+ {
+ aName = String();
+
+ // Dialog "OLE-Objekt einfuegen" aufrufen
+ GetDocSh()->SetWaitCursor( sal_False );
+ pViewShell->GetViewFrame()->GetDispatcher()->Execute(
+ SID_INSERT_OBJECT,
+ SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD);
+ xObj = pObj->GetObjRef();
+ GetDocSh()->SetWaitCursor( sal_True );
+
+ if (!xObj.is())
+ {
+ bAbort = sal_True;
+ }
+ }
+
+ if ( xObj.is() )
+ {
+ /******************************************************
+ * OLE-Objekt ist nicht mehr leer
+ ******************************************************/
+ pObj->SetEmptyPresObj(sal_False);
+ pObj->SetOutlinerParaObject(NULL);
+ pObj->SetGraphic(NULL);
+
+ /******************************************************
+ * Das leere OLE-Objekt bekommt ein neues IPObj
+ ******************************************************/
+ if (aName.Len())
+ {
+ pObj->SetObjRef(xObj);
+ pObj->SetName(aObjName);
+ pObj->SetPersistName(aObjName);
+ }
+ else
+ {
+ // Das Einfuegen hat der Dialog schon gemacht
+ pObj->SetObjRef(xObj);
+ }
+
+ Rectangle aRect = pObj->GetLogicRect();
+
+ if ( pObj->GetAspect() != embed::Aspects::MSOLE_ICON )
+ {
+ awt::Size aSz;
+ aSz.Width = aRect.GetWidth();
+ aSz.Height = aRect.GetHeight();
+ xObj->setVisualAreaSize( pObj->GetAspect(), aSz );
+ }
+
+ GetViewShellBase().SetVerbs( xObj->getSupportedVerbs() );
+
+ nVerb = SVVERB_SHOW;
+ }
+ else
+ {
+ aErrCode = ERRCODE_SFX_OLEGENERAL;
+ }
+ }
+
+ if( aErrCode == 0 )
+ {
+ ::sd::View* pView = GetView();
+
+ if (pView->IsTextEdit())
+ {
+ pView->SdrEndTextEdit();
+ }
+
+ SfxInPlaceClient* pSdClient =
+ static_cast<Client*>(pViewShell->FindIPClient(
+ pObj->GetObjRef(), GetActiveWindow()));
+
+ if ( !pSdClient )
+ {
+ pSdClient = new Client(pObj, this, GetActiveWindow());
+ }
+
+ Rectangle aRect = pObj->GetLogicRect();
+ Size aDrawSize = aRect.GetSize();
+
+ MapMode aMapMode( GetDoc()->GetScaleUnit() );
+ Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
+ if( pObj->IsChart() ) //charts never should be stretched see #i84323# for example
+ aObjAreaSize = aDrawSize;
+
+ Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() );
+ Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
+ aScaleWidth.ReduceInaccurate(10); // kompatibel zum SdrOle2Obj
+ aScaleHeight.ReduceInaccurate(10);
+ pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
+
+ // sichtbarer Ausschnitt wird nur inplace veraendert!
+ aRect.SetSize(aObjAreaSize);
+ // the object area size must be set after scaling, since it triggers the resizing
+ pSdClient->SetObjArea(aRect);
+
+ if( bChangeDefaultsForChart && xObj.is())
+ {
+ AdaptDefaultsForChart( xObj );
+ }
+
+ pSdClient->DoVerb(nVerb); // ErrCode wird ggf. vom Sfx ausgegeben
+ pViewShell->GetViewFrame()->GetBindings().Invalidate(
+ SID_NAVIGATOR_STATE, sal_True, sal_False);
+ }
+
+ GetDocSh()->SetWaitCursor( sal_False );
+
+ if (aErrCode != 0 && !bAbort)
+ {
+ ErrorHandler::HandleError(* new StringErrorInfo(aErrCode, String() ) );
+ }
+
+ return aErrCode == 0;
+}
+
+/*************************************************************************
+|*
+|* umschliessendes Rechteck aller (Split-)Fenster zurueckgeben.
+|*
+\************************************************************************/
+
+const Rectangle& ViewShell::GetAllWindowRect()
+{
+ maAllWindowRectangle.SetPos(
+ mpContentWindow->OutputToScreenPixel(Point(0,0)));
+ return maAllWindowRectangle;
+}
+
+/*************************************************************************
+|*
+|* Read user data
+|*
+\************************************************************************/
+void ViewShell::ReadUserData(const String&)
+{
+ // Auf an FrameView gemerkte VisArea zoomen
+ GetViewShell()->GetViewFrame()->GetDispatcher()->Execute(SID_SIZE_VISAREA,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD);
+}
+
+/*************************************************************************
+|*
+|* Write user data
+|*
+\************************************************************************/
+
+void ViewShell::WriteUserData(String&)
+{
+ // Das Schreiben unserer Daten erfolgt stets in WriteFrameViewData()
+ WriteFrameViewData();
+}
+
+
+/*************************************************************************
+|*
+|* Lineale ein- / ausschalten
+|*
+\************************************************************************/
+
+void ViewShell::SetRuler(sal_Bool bRuler)
+{
+ mbHasRulers = ( bRuler && !GetDocSh()->IsPreview() ); // no rulers on preview mode
+
+ if (mpHorizontalRuler.get() != NULL)
+ {
+ if (mbHasRulers)
+ {
+ mpHorizontalRuler->Show();
+ }
+ else
+ {
+ mpHorizontalRuler->Hide();
+ }
+ }
+
+ if (mpVerticalRuler.get() != NULL)
+ {
+ if (mbHasRulers)
+ {
+ mpVerticalRuler->Show();
+ }
+ else
+ {
+ mpVerticalRuler->Hide();
+ }
+ }
+
+ OSL_ASSERT(GetViewShell()!=NULL);
+ if (IsMainViewShell())
+ GetViewShell()->InvalidateBorder();
+}
+
+/*************************************************************************
+|*
+|* AcceptDrop
+|*
+\************************************************************************/
+
+sal_Int8 ViewShell::AcceptDrop (
+ const AcceptDropEvent& rEvt,
+ DropTargetHelper& rTargetHelper,
+ ::sd::Window* pTargetWindow,
+ sal_uInt16 nPage,
+ sal_uInt16 nLayer)
+{
+ ::sd::View* pView = GetView();
+ return( pView ? pView->AcceptDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
+}
+
+/*************************************************************************
+|*
+|* ExecuteDrop
+|*
+\************************************************************************/
+
+sal_Int8 ViewShell::ExecuteDrop (
+ const ExecuteDropEvent& rEvt,
+ DropTargetHelper& rTargetHelper,
+ ::sd::Window* pTargetWindow,
+ sal_uInt16 nPage,
+ sal_uInt16 nLayer)
+{
+ ::sd::View* pView = GetView();
+ return( pView ? pView->ExecuteDrop( rEvt, rTargetHelper, pTargetWindow, nPage, nLayer ) : DND_ACTION_NONE );
+}
+
+#ifdef _MSC_VER
+#pragma optimize ( "", on )
+#endif
+
+void ViewShell::WriteUserDataSequence ( ::com::sun::star::uno::Sequence <
+ ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse)
+{
+ const sal_Int32 nIndex = rSequence.getLength();
+ rSequence.realloc( nIndex + 1 );
+
+ OSL_ASSERT (GetViewShell()!=NULL);
+ // Get the view id from the view shell in the center pane. This will
+ // usually be the called view shell, but to be on the safe side we call
+ // the main view shell explicitly.
+ sal_uInt16 nViewID (IMPRESS_FACTORY_ID);
+ if (GetViewShellBase().GetMainViewShell().get() != NULL)
+ nViewID = GetViewShellBase().GetMainViewShell()->mpImpl->GetViewId();
+ rSequence[nIndex].Name = rtl::OUString (
+ RTL_CONSTASCII_USTRINGPARAM( sUNO_View_ViewId ) );
+ rtl::OUStringBuffer sBuffer (
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "view" ) ) );
+ sBuffer.append( static_cast<sal_Int32>(nViewID));
+ rSequence[nIndex].Value <<= sBuffer.makeStringAndClear();
+
+ mpFrameView->WriteUserDataSequence( rSequence, bBrowse );
+}
+
+
+void ViewShell::ReadUserDataSequence ( const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rSequence, sal_Bool bBrowse )
+{
+ mpFrameView->ReadUserDataSequence( rSequence, bBrowse );
+}
+
+void ViewShell::VisAreaChanged(const Rectangle& rRect)
+{
+ OSL_ASSERT (GetViewShell()!=NULL);
+ GetViewShell()->VisAreaChanged(rRect);
+}
+
+void ViewShell::SetWinViewPos(const Point& rWinPos, bool bUpdate)
+{
+ if (mpContentWindow.get() != NULL)
+ {
+ mpContentWindow->SetWinViewPos(rWinPos);
+
+ if ( bUpdate )
+ {
+ mpContentWindow->UpdateMapOrigin();
+ mpContentWindow->Invalidate();
+ }
+ }
+
+ if (mbHasRulers)
+ {
+ UpdateHRuler();
+ UpdateVRuler();
+ }
+
+ UpdateScrollBars();
+
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
+ VisAreaChanged(aVisAreaWin);
+
+ ::sd::View* pView = GetView();
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+}
+
+Point ViewShell::GetWinViewPos() const
+{
+ return mpContentWindow->GetWinViewPos();
+}
+
+Point ViewShell::GetViewOrigin() const
+{
+ return mpContentWindow->GetViewOrigin();
+}
+
+void ViewShell::AdaptDefaultsForChart(
+ const uno::Reference < embed::XEmbeddedObject > & xEmbObj )
+{
+ if( xEmbObj.is())
+ {
+ uno::Reference< chart2::XChartDocument > xChartDoc( xEmbObj->getComponent(), uno::UNO_QUERY );
+ OSL_ENSURE( xChartDoc.is(), "Trying to set chart property to non-chart OLE" );
+ if( !xChartDoc.is())
+ return;
+
+ try
+ {
+ // set background to transparent (none)
+ uno::Reference< beans::XPropertySet > xPageProp( xChartDoc->getPageBackground());
+ if( xPageProp.is())
+ xPageProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FillStyle")),
+ uno::makeAny( drawing::FillStyle_NONE ));
+ // set no border
+ if( xPageProp.is())
+ xPageProp->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineStyle")),
+ uno::makeAny( drawing::LineStyle_NONE ));
+ }
+ catch( const uno::Exception & )
+ {
+ OSL_ENSURE( false, "Exception caught in AdaptDefaultsForChart" );
+ }
+ }
+}
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/viewshe3.cxx b/sd/source/ui/view/viewshe3.cxx
new file mode 100644
index 000000000000..384fe3fc6b10
--- /dev/null
+++ b/sd/source/ui/view/viewshe3.cxx
@@ -0,0 +1,448 @@
+/*************************************************************************
+ *
+ * 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 "ViewShell.hxx"
+#include "GraphicViewShell.hxx"
+#include "GraphicViewShellBase.hxx"
+
+#include <sfx2/viewfrm.hxx>
+#include <svtools/svtools.hrc>
+#include <com/sun/star/lang/Locale.hpp>
+#include <svtools/svtdata.hxx>
+#include <utility>
+#include <vector>
+
+#include "app.hrc"
+#include "strings.hrc"
+#include "res_bmp.hrc"
+#include "glob.hrc"
+#include "sdabstdlg.hxx"
+
+#include "fupoor.hxx"
+#include <sfx2/dispatch.hxx>
+#include <svx/prtqry.hxx>
+#include <svx/svdopage.hxx>
+#include <sfx2/progress.hxx>
+#include <svx/svdobj.hxx>
+#include <vcl/msgbox.hxx>
+#include <sfx2/bindings.hxx>
+#include <svx/svdpagv.hxx>
+#include <svx/svdetc.hxx>
+#include <editeng/outliner.hxx>
+#include <editeng/editstat.hxx>
+#include <tools/multisel.hxx>
+#include <svl/intitem.hxx>
+#include <svl/style.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <rtl/ustrbuf.hxx>
+#include "stlsheet.hxx"
+#ifndef SD_WINDOW_UPDATER_HXX
+#include "WindowUpdater.hxx"
+#endif
+#include "DrawViewShell.hxx"
+#include "OutlineViewShell.hxx"
+#include "drawview.hxx"
+
+#include "sdattr.hxx"
+#include "drawdoc.hxx"
+#include "sdpage.hxx"
+#include "unoaprms.hxx" // Undo-Action
+#include "sdundogr.hxx" // Undo Gruppe
+#include "Window.hxx"
+#include "DrawDocShell.hxx"
+#include "FrameView.hxx"
+#include "framework/FrameworkHelper.hxx"
+#include "optsitem.hxx"
+#include "sdresid.hxx"
+
+// #96090#
+#ifndef _SVXIDS_HXX
+#include <svx/svxids.hrc>
+#endif
+#include <sfx2/request.hxx>
+#include <svl/aeitem.hxx>
+#include <basic/sbstar.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::rtl;
+
+namespace sd {
+
+/*************************************************************************
+|*
+|* Status (Enabled/Disabled) von Menue-SfxSlots setzen
+|*
+\************************************************************************/
+
+void ViewShell::GetMenuState( SfxItemSet &rSet )
+{
+ if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_STYLE_FAMILY ) )
+ {
+ sal_uInt16 nFamily = (sal_uInt16)GetDocSh()->GetStyleFamily();
+
+ SdrView* pDrView = GetDrawView();
+
+ if( pDrView->AreObjectsMarked() )
+ {
+ SfxStyleSheet* pStyleSheet = pDrView->GetStyleSheet();
+ if( pStyleSheet )
+ {
+ if (pStyleSheet->GetFamily() == SD_STYLE_FAMILY_MASTERPAGE)
+ pStyleSheet = ((SdStyleSheet*)pStyleSheet)->GetPseudoStyleSheet();
+
+ if( pStyleSheet )
+ {
+ SfxStyleFamily eFamily = pStyleSheet->GetFamily();
+ if(eFamily == SD_STYLE_FAMILY_GRAPHICS)
+ nFamily = 2;
+ else if(eFamily == SD_STYLE_FAMILY_CELL )
+ nFamily = 3;
+ else // SD_STYLE_FAMILY_PSEUDO
+ nFamily = 5;
+
+ GetDocSh()->SetStyleFamily(nFamily);
+ }
+ }
+ }
+ rSet.Put(SfxUInt16Item(SID_STYLE_FAMILY, nFamily ));
+ }
+
+ // #96090#
+ if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETUNDOSTRINGS))
+ {
+ ImpGetUndoStrings(rSet);
+ }
+
+ // #96090#
+ if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_GETREDOSTRINGS))
+ {
+ ImpGetRedoStrings(rSet);
+ }
+
+ // #96090#
+ if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_UNDO))
+ {
+ ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
+ sal_Bool bActivate(sal_False);
+
+ if(pUndoManager)
+ {
+ if(pUndoManager->GetUndoActionCount() != 0)
+ {
+ bActivate = sal_True;
+ }
+ }
+
+ if(bActivate)
+ {
+ // #87229# Set the necessary string like in
+ // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1072 ff.
+ String aTmp( SvtResId( STR_UNDO ) );
+ aTmp += pUndoManager->GetUndoActionComment(0);
+ rSet.Put(SfxStringItem(SID_UNDO, aTmp));
+ }
+ else
+ {
+ rSet.DisableItem(SID_UNDO);
+ }
+ }
+
+ // #96090#
+ if(SFX_ITEM_AVAILABLE == rSet.GetItemState(SID_REDO))
+ {
+ ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
+ sal_Bool bActivate(sal_False);
+
+ if(pUndoManager)
+ {
+ if(pUndoManager->GetRedoActionCount() != 0)
+ {
+ bActivate = sal_True;
+ }
+ }
+
+ if(bActivate)
+ {
+ // #87229# Set the necessary string like in
+ // sfx2/source/view/viewfrm.cxx ver 1.23 ln 1081 ff.
+ String aTmp(SvtResId(STR_REDO));
+ aTmp += pUndoManager->GetRedoActionComment(0);
+ rSet.Put(SfxStringItem(SID_REDO, aTmp));
+ }
+ else
+ {
+ rSet.DisableItem(SID_REDO);
+ }
+ }
+}
+
+
+
+
+/** This method consists basically of three parts:
+ 1. Process the arguments of the SFX request.
+ 2. Use the model to create a new page or duplicate an existing one.
+ 3. Update the tab control and switch to the new page.
+*/
+SdPage* ViewShell::CreateOrDuplicatePage (
+ SfxRequest& rRequest,
+ PageKind ePageKind,
+ SdPage* pPage,
+ const sal_Int32 nInsertPosition)
+{
+ sal_uInt16 nSId = rRequest.GetSlot();
+ SdDrawDocument* pDocument = GetDoc();
+ SdrLayerAdmin& rLayerAdmin = pDocument->GetLayerAdmin();
+ sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
+ sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
+ SetOfByte aVisibleLayers;
+ // Determine the page from which to copy some values, such as layers,
+ // size, master page, to the new page. This is usually the given page.
+ // When the given page is NULL then use the first page of the document.
+ SdPage* pTemplatePage = pPage;
+ if (pTemplatePage == NULL)
+ if (pDocument->GetSdPage(0, ePageKind) > 0)
+ pTemplatePage = pDocument->GetSdPage(0, ePageKind);
+ if (pTemplatePage != NULL && pTemplatePage->TRG_HasMasterPage())
+ aVisibleLayers = pTemplatePage->TRG_GetMasterPageVisibleLayers();
+ else
+ aVisibleLayers.SetAll();
+
+ String aStandardPageName;
+ String aNotesPageName;
+ AutoLayout eStandardLayout (AUTOLAYOUT_NONE);
+ AutoLayout eNotesLayout (AUTOLAYOUT_NOTES);
+ sal_Bool bIsPageBack = aVisibleLayers.IsSet(aBckgrnd);
+ sal_Bool bIsPageObj = aVisibleLayers.IsSet(aBckgrndObj);
+
+ // 1. Process the arguments.
+ const SfxItemSet* pArgs = rRequest.GetArgs();
+ if (! pArgs)
+ {
+/*
+ // Make the layout menu visible in the tool pane.
+ const ViewShellBase& rBase (GetViewShellBase());
+ if (rBase.GetMainViewShell()!=NULL
+ && rBase.GetMainViewShell()->GetShellType()!=ViewShell::ST_OUTLINE
+ && rBase.GetMainViewShell()->GetShellType()!=ViewShell::ST_DRAW)
+ {
+ framework::FrameworkHelper::Instance(GetViewShellBase())->RequestTaskPanel(
+ framework::FrameworkHelper::msLayoutTaskPanelURL,
+ false);
+ }
+*/
+
+ // AutoLayouts muessen fertig sein
+ pDocument->StopWorkStartupDelay();
+
+ // Use the layouts of the previous page and notes page as template.
+ if (pTemplatePage != NULL)
+ {
+ eStandardLayout = pTemplatePage->GetAutoLayout();
+ if( eStandardLayout == AUTOLAYOUT_TITLE )
+ eStandardLayout = AUTOLAYOUT_ENUM;
+
+ SdPage* pNotesTemplatePage = static_cast<SdPage*>(pDocument->GetPage(pTemplatePage->GetPageNum()+1));
+ if (pNotesTemplatePage != NULL)
+ eNotesLayout = pNotesTemplatePage->GetAutoLayout();
+ }
+ }
+ else if (pArgs->Count() == 1)
+ {
+ pDocument->StopWorkStartupDelay();
+ SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
+ if( pLayout )
+ {
+ if (ePageKind == PK_NOTES)
+ {
+ eNotesLayout = (AutoLayout) pLayout->GetValue ();
+ }
+ else
+ {
+ eStandardLayout = (AutoLayout) pLayout->GetValue ();
+ }
+ }
+ }
+ else if (pArgs->Count() == 4)
+ {
+ // AutoLayouts muessen fertig sein
+ pDocument->StopWorkStartupDelay();
+
+ SFX_REQUEST_ARG (rRequest, pPageName, SfxStringItem, ID_VAL_PAGENAME, sal_False);
+ SFX_REQUEST_ARG (rRequest, pLayout, SfxUInt32Item, ID_VAL_WHATLAYOUT, sal_False);
+ SFX_REQUEST_ARG (rRequest, pIsPageBack, SfxBoolItem, ID_VAL_ISPAGEBACK, sal_False);
+ SFX_REQUEST_ARG (rRequest, pIsPageObj, SfxBoolItem, ID_VAL_ISPAGEOBJ, sal_False);
+
+ if (CHECK_RANGE (AUTOLAYOUT__START, (AutoLayout) pLayout->GetValue (), AUTOLAYOUT__END))
+ {
+ if (ePageKind == PK_NOTES)
+ {
+ aNotesPageName = pPageName->GetValue ();
+ eNotesLayout = (AutoLayout) pLayout->GetValue ();
+ }
+ else
+ {
+ aStandardPageName = pPageName->GetValue ();
+ eStandardLayout = (AutoLayout) pLayout->GetValue ();
+ }
+
+ bIsPageBack = pIsPageBack->GetValue ();
+ bIsPageObj = pIsPageObj->GetValue ();
+ }
+ else
+ {
+ Cancel();
+
+ if(HasCurrentFunction( SID_BEZIER_EDIT ) )
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+
+ StarBASIC::FatalError (SbERR_BAD_PROP_VALUE);
+ rRequest.Ignore ();
+ return NULL;
+ }
+ }
+ else
+ {
+ Cancel();
+
+ if(HasCurrentFunction(SID_BEZIER_EDIT) )
+ GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+
+ StarBASIC::FatalError (SbERR_WRONG_ARGS);
+ rRequest.Ignore ();
+ return NULL;
+ }
+
+ // 2. Create a new page or duplicate an existing one.
+ View* pDrView = GetView();
+ const bool bUndo = pDrView && pDrView->IsUndoEnabled();
+ if( bUndo )
+ pDrView->BegUndo( String( SdResId(STR_INSERTPAGE) ) );
+
+ sal_uInt16 nNewPageIndex = 0xffff;
+ switch (nSId)
+ {
+ case SID_INSERTPAGE:
+ case SID_INSERTPAGE_QUICK:
+ case SID_INSERT_MASTER_PAGE:
+ // There are three cases. a) pPage is not NULL: we use it as a
+ // template and create a new slide behind it. b) pPage is NULL
+ // but the document is not empty: we use the first slide/notes
+ // page as template, create a new slide after it and move it
+ // then to the head of the document. c) pPage is NULL and the
+ // document is empty: We use CreateFirstPages to create the
+ // first page of the document.
+ if (pPage == NULL)
+ if (pTemplatePage == NULL)
+ {
+ pDocument->CreateFirstPages();
+ nNewPageIndex = 0;
+ }
+ else
+ {
+ // Create a new page with the first page as template and
+ // insert it after the first page.
+ nNewPageIndex = pDocument->CreatePage (
+ pTemplatePage,
+ ePageKind,
+ aStandardPageName,
+ aNotesPageName,
+ eStandardLayout,
+ eNotesLayout,
+ bIsPageBack,
+ bIsPageObj,
+ nInsertPosition);
+ // Select exactly the new page.
+ sal_uInt16 nPageCount (pDocument->GetSdPageCount(ePageKind));
+ for (sal_uInt16 i=0; i<nPageCount; i++)
+ {
+ pDocument->GetSdPage(i, PK_STANDARD)->SetSelected(
+ i == nNewPageIndex);
+ pDocument->GetSdPage(i, PK_NOTES)->SetSelected(
+ i == nNewPageIndex);
+ }
+ // Move the selected page to the head of the document
+ pDocument->MovePages ((sal_uInt16)-1);
+ nNewPageIndex = 0;
+ }
+ else
+ nNewPageIndex = pDocument->CreatePage (
+ pPage,
+ ePageKind,
+ aStandardPageName,
+ aNotesPageName,
+ eStandardLayout,
+ eNotesLayout,
+ bIsPageBack,
+ bIsPageObj,
+ nInsertPosition);
+ break;
+
+ case SID_DUPLICATE_PAGE:
+ // Duplication makes no sense when pPage is NULL.
+ if (pPage != NULL)
+ nNewPageIndex = pDocument->DuplicatePage (
+ pPage,
+ ePageKind,
+ aStandardPageName,
+ aNotesPageName,
+ eStandardLayout,
+ eNotesLayout,
+ bIsPageBack,
+ bIsPageObj,
+ nInsertPosition);
+ break;
+
+ default:
+ DBG_WARNING("wrong slot id given to CreateOrDuplicatePage");
+ // Try to handle another slot id gracefully.
+ }
+ SdPage* pNewPage = 0;
+ if(nNewPageIndex != 0xffff)
+ pNewPage = pDocument->GetSdPage(nNewPageIndex, PK_STANDARD);
+
+ if( bUndo )
+ {
+ if( pNewPage )
+ {
+ pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pNewPage));
+ pDrView->AddUndo(pDocument->GetSdrUndoFactory().CreateUndoNewPage(*pDocument->GetSdPage (nNewPageIndex, PK_NOTES)));
+ }
+
+ pDrView->EndUndo();
+ }
+
+ return pNewPage;
+}
+
+
+} // end of namespace sd
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
new file mode 100755
index 000000000000..62ea8a71407e
--- /dev/null
+++ b/sd/source/ui/view/viewshel.cxx
@@ -0,0 +1,1636 @@
+/*************************************************************************
+ *
+ * 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 "ViewShell.hxx"
+#include "ViewShellImplementation.hxx"
+
+#ifndef _COM_SUN_STAR_EMBED_EMBEDSTATE_HPP_
+#include <com/sun/star/embed/EmbedStates.hpp>
+#endif
+#include "ViewShellBase.hxx"
+#include "ShellFactory.hxx"
+#include "DrawController.hxx"
+#include "LayerTabBar.hxx"
+
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#ifndef _SCRBAR_HXX //autogen
+#include <vcl/scrbar.hxx>
+#endif
+#include <svl/eitem.hxx>
+#include <svx/ruler.hxx>
+#ifndef _SVXIDS_HXX
+#include <svx/svxids.hrc>
+#endif
+#include <svx/fmshell.hxx>
+#ifndef SD_WINDOW_UPDATER_HXX
+#include "WindowUpdater.hxx"
+#endif
+#include "GraphicViewShell.hxx"
+#include <sfx2/childwin.hxx>
+#include <sdxfer.hxx>
+#include "GraphicViewShell.hxx"
+#include <sfx2/childwin.hxx>
+
+#include "app.hrc"
+#include "helpids.h"
+#include "strings.hrc"
+#include "res_bmp.hrc"
+#include "OutlineView.hxx"
+#include "Client.hxx"
+#include "sdresid.hxx"
+#include "DrawDocShell.hxx"
+#include "slideshow.hxx"
+#include "drawdoc.hxx"
+#include "sdpage.hxx"
+#include "zoomlist.hxx"
+#include "FrameView.hxx"
+#include "optsitem.hxx"
+#include "BezierObjectBar.hxx"
+#include "TextObjectBar.hxx"
+#include "GraphicObjectBar.hxx"
+#include "MediaObjectBar.hxx"
+#include "ViewShellManager.hxx"
+#include "FormShellManager.hxx"
+#include <svx/fmshell.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/extrusionbar.hxx>
+#include <svx/fontworkbar.hxx>
+#include <svx/svdoutl.hxx>
+#include <tools/diagnose_ex.h>
+
+// #96090#
+#include <svl/slstitm.hxx>
+#include <sfx2/request.hxx>
+#include "SpellDialogChildWindow.hxx"
+
+#include "Window.hxx"
+#include "fupoor.hxx"
+
+#ifndef SO2_DECL_SVINPLACEOBJECT_DEFINED
+#define SO2_DECL_SVINPLACEOBJECT_DEFINED
+SO2_DECL_REF(SvInPlaceObject)
+#endif
+
+namespace sd { namespace ui { namespace table {
+ extern SfxShell* CreateTableObjectBar( ViewShell& rShell, ::sd::View* pView );
+} } }
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::presentation;
+
+namespace {
+
+class ViewShellObjectBarFactory
+ : public ::sd::ShellFactory<SfxShell>
+{
+public:
+ ViewShellObjectBarFactory (::sd::ViewShell& rViewShell);
+ virtual ~ViewShellObjectBarFactory (void);
+ virtual SfxShell* CreateShell (
+ ::sd::ShellId nId,
+ ::Window* pParentWindow,
+ ::sd::FrameView* pFrameView);
+ virtual void ReleaseShell (SfxShell* pShell);
+private:
+ ::sd::ViewShell& mrViewShell;
+ /** This cache holds the already created object bars.
+ */
+ typedef ::std::map< ::sd::ShellId,SfxShell*> ShellCache;
+ ShellCache maShellCache;
+};
+
+
+} // end of anonymous namespace
+
+
+namespace sd {
+
+static const int DELTA_ZOOM = 10;
+
+sal_Bool ViewShell::IsPageFlipMode(void) const
+{
+ return this->ISA(DrawViewShell) && mpContentWindow.get() != NULL &&
+ mpContentWindow->GetVisibleHeight() >= 1.0;
+}
+
+SfxViewFrame* ViewShell::GetViewFrame (void) const
+{
+ const SfxViewShell* pViewShell = GetViewShell();
+ if (pViewShell != NULL)
+ {
+ return pViewShell->GetViewFrame();
+ }
+ else
+ {
+ OSL_ASSERT (GetViewShell()!=NULL);
+ return NULL;
+ }
+}
+
+
+/*************************************************************************
+|*
+|* SFX-Slotmap und Standardinterface deklarieren
+|*
+\************************************************************************/
+TYPEINIT1(ViewShell, SfxShell);
+
+
+ViewShell::ViewShell( SfxViewFrame*, ::Window* pParentWindow, ViewShellBase& rViewShellBase, bool bAllowCenter)
+: SfxShell(&rViewShellBase)
+, mbCenterAllowed(bAllowCenter)
+, mpParentWindow(pParentWindow)
+{
+ construct();
+}
+
+ViewShell::~ViewShell()
+{
+ // Keep the content window from accessing in its destructor the
+ // WindowUpdater.
+ mpContentWindow->SetViewShell(NULL);
+
+ delete mpZoomList;
+
+ mpLayerTabBar.reset();
+
+ if (mpImpl->mpSubShellFactory.get() != NULL)
+ GetViewShellBase().GetViewShellManager()->RemoveSubShellFactory(
+ this,mpImpl->mpSubShellFactory);
+}
+
+
+/*************************************************************************
+|*
+|* gemeinsamer Initialiserungsanteil der beiden Konstruktoren
+|*
+\************************************************************************/
+
+void ViewShell::construct(void)
+{
+ mbHasRulers = false;
+ mpActiveWindow = 0;
+ mpView = 0;
+ mpFrameView = 0;
+ mpZoomList = 0;
+ mbStartShowWithDialog = sal_False;
+ mnPrintedHandoutPageNum = 1;
+ mnPrintedHandoutPageCount = 0;
+ mpWindowUpdater.reset( new ::sd::WindowUpdater() );
+ mpImpl.reset(new Implementation(*this));
+ meShellType = ST_NONE;
+
+ OSL_ASSERT (GetViewShell()!=NULL);
+
+ if (IsMainViewShell())
+ GetDocSh()->Connect (this);
+
+ mpZoomList = new ZoomList( this );
+
+ mpContentWindow.reset(new ::sd::Window(GetParentWindow()));
+ SetActiveWindow (mpContentWindow.get());
+
+ GetParentWindow()->SetBackground (Wallpaper());
+ mpContentWindow->SetBackground (Wallpaper());
+ mpContentWindow->SetCenterAllowed(mbCenterAllowed);
+ mpContentWindow->SetViewShell(this);
+ mpContentWindow->SetPosSizePixel(
+ GetParentWindow()->GetPosPixel(),GetParentWindow()->GetSizePixel());
+ mpContentWindow->Show();
+ static_cast< ::Window*>(mpContentWindow.get())->Resize();
+ OSL_TRACE("content window has size %d %d",
+ mpContentWindow->GetSizePixel().Width(),
+ mpContentWindow->GetSizePixel().Height());
+
+ if ( ! GetDocSh()->IsPreview())
+ {
+ // Create scroll bars and the filler between the scroll bars.
+ mpHorizontalScrollBar.reset (new ScrollBar(GetParentWindow(), WinBits(WB_HSCROLL | WB_DRAG)));
+ mpHorizontalScrollBar->EnableRTL (sal_False);
+ mpHorizontalScrollBar->SetRange(Range(0, 32000));
+ mpHorizontalScrollBar->SetScrollHdl(LINK(this, ViewShell, HScrollHdl));
+ mpHorizontalScrollBar->Show();
+
+ mpVerticalScrollBar.reset (new ScrollBar(GetParentWindow(), WinBits(WB_VSCROLL | WB_DRAG)));
+ mpVerticalScrollBar->SetRange(Range(0, 32000));
+ mpVerticalScrollBar->SetScrollHdl(LINK(this, ViewShell, VScrollHdl));
+ mpVerticalScrollBar->Show();
+ maScrBarWH = Size(
+ mpVerticalScrollBar->GetSizePixel().Width(),
+ mpHorizontalScrollBar->GetSizePixel().Height());
+
+ mpScrollBarBox.reset(new ScrollBarBox(GetParentWindow(), WB_SIZEABLE));
+ mpScrollBarBox->Show();
+ }
+
+ String aName( RTL_CONSTASCII_USTRINGPARAM( "ViewShell" ));
+ SetName (aName);
+
+ GetDoc()->StartOnlineSpelling(sal_False);
+
+ mpWindowUpdater->SetViewShell (*this);
+ mpWindowUpdater->SetDocument (GetDoc());
+
+ // Re-initialize the spell dialog.
+ ::sd::SpellDialogChildWindow* pSpellDialog =
+ static_cast< ::sd::SpellDialogChildWindow*> (
+ GetViewFrame()->GetChildWindow (
+ ::sd::SpellDialogChildWindow::GetChildWindowId()));
+ if (pSpellDialog != NULL)
+ pSpellDialog->InvalidateSpellDialog();
+
+ // Register the sub shell factory.
+ mpImpl->mpSubShellFactory.reset(new ViewShellObjectBarFactory(*this));
+ GetViewShellBase().GetViewShellManager()->AddSubShellFactory(this,mpImpl->mpSubShellFactory);
+
+ GetParentWindow()->Show();
+}
+
+
+
+
+void ViewShell::Init (bool bIsMainViewShell)
+{
+ mpImpl->mbIsInitialized = true;
+ SetIsMainViewShell(bIsMainViewShell);
+ if (bIsMainViewShell)
+ SetActiveWindow (mpContentWindow.get());
+}
+
+
+
+
+void ViewShell::Exit (void)
+{
+ sd::View* pView = GetView();
+ if (pView!=NULL && pView->IsTextEdit())
+ {
+ pView->SdrEndTextEdit();
+ pView->UnmarkAll();
+ }
+
+ Deactivate (sal_True);
+
+ if (IsMainViewShell())
+ {
+ GetDocSh()->Disconnect(this);
+ }
+
+ SetIsMainViewShell(false);
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Aktivierung: Arbeitsfenster den Fokus zuweisen
+|*
+\************************************************************************/
+
+void ViewShell::Activate(sal_Bool bIsMDIActivate)
+{
+ SfxShell::Activate(bIsMDIActivate);
+
+ // Laut MI darf keiner GrabFocus rufen, der nicht genau weiss von
+ // welchem Window der Focus gegrabt wird. Da Activate() vom SFX teilweise
+ // asynchron verschickt wird, kann es sein, dass ein falsches Window
+ // den Focus hat (#29682#):
+ //GetViewFrame()->GetWindow().GrabFocus();
+
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->SetActive(sal_True);
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->SetActive(sal_True);
+
+ if (bIsMDIActivate)
+ {
+ // Damit der Navigator auch einen aktuellen Status bekommt
+ SfxBoolItem aItem( SID_NAVIGATOR_INIT, sal_True );
+ if (GetDispatcher() != NULL)
+ GetDispatcher()->Execute(
+ SID_NAVIGATOR_INIT,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aItem,
+ 0L);
+
+ SfxViewShell* pViewShell = GetViewShell();
+ OSL_ASSERT (pViewShell!=NULL);
+ SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_3D_STATE, sal_True, sal_False );
+
+ rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if(xSlideShow.is() && xSlideShow->isRunning() )
+ {
+ xSlideShow->activate(GetViewShellBase());
+ }
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->Activate();
+ }
+
+ if(!GetDocSh()->IsUIActive())
+ UpdatePreview( GetActualPage(), sal_True );
+
+ //HMH::sd::View* pView = GetView();
+
+ //HMHif (pView)
+ //HMH{
+ //HMH pView->ShowMarkHdl();
+ //HMH}
+ }
+
+ ReadFrameViewData( mpFrameView );
+
+ if (IsMainViewShell())
+ GetDocSh()->Connect(this);
+}
+
+void ViewShell::UIActivating( SfxInPlaceClient* )
+{
+ OSL_ASSERT (GetViewShell()!=NULL);
+ GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed();
+}
+
+
+
+void ViewShell::UIDeactivated( SfxInPlaceClient* )
+{
+ OSL_ASSERT (GetViewShell()!=NULL);
+ GetViewShellBase().GetToolBarManager()->ToolBarsDestroyed();
+ if ( GetDrawView() )
+ GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this, *GetDrawView());
+}
+
+/*************************************************************************
+|*
+|* Deaktivierung
+|*
+\************************************************************************/
+
+void ViewShell::Deactivate(sal_Bool bIsMDIActivate)
+{
+ // remove view from a still active drag'n'drop session
+ SdTransferable* pDragTransferable = SD_MOD()->pTransferDrag;
+
+ if (IsMainViewShell())
+ GetDocSh()->Disconnect(this);
+
+ if( pDragTransferable )
+ pDragTransferable->SetView( NULL );
+
+ OSL_ASSERT (GetViewShell()!=NULL);
+
+ // View-Attribute an der FrameView merken
+ WriteFrameViewData();
+
+ if (bIsMDIActivate)
+ {
+ rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if(xSlideShow.is() && xSlideShow->isRunning() )
+ {
+ xSlideShow->deactivate(GetViewShellBase());
+ }
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->Deactivate();
+ }
+ }
+
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->SetActive(sal_False);
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->SetActive(sal_False);
+
+ SfxShell::Deactivate(bIsMDIActivate);
+}
+
+
+
+
+void ViewShell::Shutdown (void)
+{
+ Exit ();
+}
+
+
+
+
+/*************************************************************************
+|*
+|* Keyboard event
+|*
+\************************************************************************/
+
+sal_Bool ViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
+{
+ sal_Bool bReturn(sal_False);
+
+ if(pWin)
+ {
+ SetActiveWindow(pWin);
+ }
+
+ if(!bReturn)
+ {
+ // #76008#
+ // give key input first to SfxViewShell to give CTRL+Key
+ // (e.g. CTRL+SHIFT+'+', to front) priority.
+ OSL_ASSERT (GetViewShell()!=NULL);
+ bReturn = (sal_Bool)GetViewShell()->KeyInput(rKEvt);
+ }
+
+ if(!bReturn)
+ {
+ rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+ if(xSlideShow.is() && xSlideShow->isRunning())
+ {
+ bReturn = xSlideShow->keyInput(rKEvt);
+ }
+ else
+ {
+ bool bConsumed = false;
+ if( GetView() )
+ bConsumed = GetView()->getSmartTags().KeyInput(rKEvt);
+
+
+ if( !bConsumed )
+ {
+ rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() );
+ if( !xSelectionController.is() || !xSelectionController->onKeyInput( rKEvt, pWin ) )
+ {
+ if(HasCurrentFunction())
+ bReturn = GetCurrentFunction()->KeyInput(rKEvt);
+ }
+ else
+ {
+ bReturn = sal_True;
+ }
+ }
+ }
+ }
+
+ if(!bReturn && GetActiveWindow())
+ {
+ KeyCode aKeyCode = rKEvt.GetKeyCode();
+
+ if (aKeyCode.IsMod1() && aKeyCode.IsShift()
+ && aKeyCode.GetCode() == KEY_R)
+ {
+ InvalidateWindows();
+ bReturn = sal_True;
+ }
+ }
+
+ return(bReturn);
+}
+
+/*************************************************************************
+|*
+|* MouseButtonDown event
+|*
+\************************************************************************/
+
+void ViewShell::MouseButtonDown(const MouseEvent& rMEvt, ::sd::Window* pWin)
+{
+ // We have to lock tool bar updates while the mouse button is pressed in
+ // order to prevent the shape under the mouse to be moved (this happens
+ // when the number of docked tool bars changes as result of a changed
+ // selection; this changes the window size and thus the mouse position
+ // in model coordinates: with respect to model coordinates the mouse
+ // moves.)
+ OSL_ASSERT(mpImpl->mpUpdateLockForMouse.expired());
+ mpImpl->mpUpdateLockForMouse = ViewShell::Implementation::ToolBarManagerLock::Create(
+ GetViewShellBase().GetToolBarManager());
+
+ if ( pWin && !pWin->HasFocus() )
+ {
+ pWin->GrabFocus();
+ SetActiveWindow(pWin);
+// GetViewFrame()->GetWindow().GrabFocus();
+ }
+
+ // MouseEvent in E3dView eintragen
+ if (GetView() != NULL)
+ GetView()->SetMouseEvent(rMEvt);
+
+ bool bConsumed = false;
+ if( GetView() )
+ bConsumed = GetView()->getSmartTags().MouseButtonDown( rMEvt );
+
+ if( !bConsumed )
+ {
+ rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() );
+ if( !xSelectionController.is() || !xSelectionController->onMouseButtonDown( rMEvt, pWin ) )
+ {
+ if(HasCurrentFunction())
+ {
+ GetCurrentFunction()->MouseButtonDown(rMEvt);
+ }
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* MouseMove event
+|*
+\************************************************************************/
+
+void ViewShell::MouseMove(const MouseEvent& rMEvt, ::sd::Window* pWin)
+{
+ if (rMEvt.IsLeaveWindow())
+ {
+ if ( ! mpImpl->mpUpdateLockForMouse.expired())
+ {
+ ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> pLock(
+ mpImpl->mpUpdateLockForMouse);
+ if (pLock.get() != NULL)
+ pLock->Release();
+ }
+ }
+
+ if ( pWin )
+ {
+ SetActiveWindow(pWin);
+ }
+
+ // MouseEvent in E3dView eintragen
+ if (GetView() != NULL)
+ GetView()->SetMouseEvent(rMEvt);
+
+ if(HasCurrentFunction())
+ {
+ rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() );
+ if( !xSelectionController.is() || !xSelectionController->onMouseMove( rMEvt, pWin ) )
+ {
+ if(HasCurrentFunction())
+ GetCurrentFunction()->MouseMove(rMEvt);
+ }
+ }
+}
+
+/*************************************************************************
+|*
+|* MouseButtonUp event
+|*
+\************************************************************************/
+
+void ViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
+{
+ if ( pWin )
+ {
+ SetActiveWindow(pWin);
+ }
+
+ // MouseEvent in E3dView eintragen
+ if (GetView() != NULL)
+ GetView()->SetMouseEvent(rMEvt);
+
+ if( HasCurrentFunction())
+ {
+ rtl::Reference< sdr::SelectionController > xSelectionController( GetView()->getSelectionController() );
+ if( !xSelectionController.is() || !xSelectionController->onMouseButtonUp( rMEvt, pWin ) )
+ {
+ if(HasCurrentFunction())
+ GetCurrentFunction()->MouseButtonUp(rMEvt);
+ }
+ }
+
+ if ( ! mpImpl->mpUpdateLockForMouse.expired())
+ {
+ ::boost::shared_ptr<ViewShell::Implementation::ToolBarManagerLock> pLock(
+ mpImpl->mpUpdateLockForMouse);
+ if (pLock.get() != NULL)
+ pLock->Release();
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Command event
+|*
+\************************************************************************/
+
+void ViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
+{
+ sal_Bool bDone = HandleScrollCommand (rCEvt, pWin);
+
+ if( !bDone )
+ {
+ if( rCEvt.GetCommand() == COMMAND_INPUTLANGUAGECHANGE )
+ {
+ //#i42732# update state of fontname if input language changes
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONT );
+ GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
+ }
+ else
+ {
+ bool bConsumed = false;
+ if( GetView() )
+ {
+ bConsumed = GetView()->getSmartTags().Command(rCEvt);
+ }
+
+ if( !bConsumed && HasCurrentFunction())
+ {
+ GetCurrentFunction()->Command(rCEvt);
+ }
+ }
+ }
+}
+
+long ViewShell::Notify(NotifyEvent& rNEvt, ::sd::Window* pWin)
+{
+ // handle scroll commands when they arrived at child windows
+ long nRet = sal_False;
+ if( rNEvt.GetType() == EVENT_COMMAND )
+ {
+ // note: dynamic_cast is not possible as GetData() returns a void*
+ CommandEvent* pCmdEvent = reinterpret_cast< CommandEvent* >(rNEvt.GetData());
+ nRet = HandleScrollCommand(*pCmdEvent, pWin);
+ }
+ return nRet;
+}
+
+
+bool ViewShell::HandleScrollCommand(const CommandEvent& rCEvt, ::sd::Window* pWin)
+{
+ bool bDone = false;
+
+ switch( rCEvt.GetCommand() )
+ {
+ case COMMAND_WHEEL:
+ {
+ Reference< XSlideShowController > xSlideShowController( SlideShow::GetSlideShowController(GetViewShellBase() ) );
+ if( xSlideShowController.is() )
+ {
+ // We ignore zooming with control+mouse wheel.
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+ if( pData && !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) && !pData->IsHorz() )
+ {
+ long nDelta = pData->GetDelta();
+ if( nDelta > 0 )
+ {
+ xSlideShowController->gotoPreviousSlide();
+ }
+ else if( nDelta < 0 )
+ {
+ xSlideShowController->gotoNextEffect();
+ }
+ }
+ break;
+ }
+ }
+ // fall through when not running slideshow
+ case COMMAND_STARTAUTOSCROLL:
+ case COMMAND_AUTOSCROLL:
+ {
+ const CommandWheelData* pData = rCEvt.GetWheelData();
+
+ if (pData != NULL)
+ {
+ if (pData->IsMod1())
+ {
+ if( !GetDocSh()->IsUIActive() )
+ {
+ const long nOldZoom = GetActiveWindow()->GetZoom();
+ long nNewZoom;
+
+ if( pData->GetDelta() < 0L )
+ nNewZoom = Max( (long) pWin->GetMinZoom(), (long)(nOldZoom - DELTA_ZOOM) );
+ else
+ nNewZoom = Min( (long) pWin->GetMaxZoom(), (long)(nOldZoom + DELTA_ZOOM) );
+
+ SetZoom( nNewZoom );
+ Invalidate( SID_ATTR_ZOOM );
+ Invalidate( SID_ATTR_ZOOMSLIDER );
+
+ bDone = true;
+ }
+ }
+ else
+ {
+ if( mpContentWindow.get() == pWin )
+ {
+ sal_uLong nScrollLines = pData->GetScrollLines();
+ if(IsPageFlipMode())
+ nScrollLines = COMMAND_WHEEL_PAGESCROLL;
+ CommandWheelData aWheelData( pData->GetDelta(),pData->GetNotchDelta(),
+ nScrollLines,pData->GetMode(),pData->GetModifier(),pData->IsHorz() );
+ CommandEvent aReWrite( rCEvt.GetMousePosPixel(),rCEvt.GetCommand(),
+ rCEvt.IsMouseEvent(),(const void *) &aWheelData );
+ bDone = pWin->HandleScrollCommand( aReWrite,
+ mpHorizontalScrollBar.get(),
+ mpVerticalScrollBar.get()) == sal_True;
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return bDone;
+}
+
+
+
+void ViewShell::SetupRulers (void)
+{
+ if(mbHasRulers && (mpContentWindow.get() != NULL) && !SlideShow::IsRunning(GetViewShellBase()))
+ {
+ long nHRulerOfs = 0;
+
+ if ( mpVerticalRuler.get() == NULL )
+ {
+ mpVerticalRuler.reset(CreateVRuler(GetActiveWindow()));
+ if ( mpVerticalRuler.get() != NULL )
+ {
+ nHRulerOfs = mpVerticalRuler->GetSizePixel().Width();
+ mpVerticalRuler->SetActive(sal_True);
+ mpVerticalRuler->Show();
+ }
+ }
+ if ( mpHorizontalRuler.get() == NULL )
+ {
+ mpHorizontalRuler.reset(CreateHRuler(GetActiveWindow(), sal_True));
+ if ( mpHorizontalRuler.get() != NULL )
+ {
+ mpHorizontalRuler->SetWinPos(nHRulerOfs);
+ mpHorizontalRuler->SetActive(sal_True);
+ mpHorizontalRuler->Show();
+ }
+ }
+ }
+}
+
+
+
+
+sal_Bool ViewShell::HasRuler (void)
+{
+ return mbHasRulers;
+}
+
+
+
+
+void ViewShell::Resize (void)
+{
+ SetupRulers ();
+
+ if (mpParentWindow == NULL)
+ return;
+
+ // Make sure that the new size is not degenerate.
+ const Size aSize (mpParentWindow->GetSizePixel());
+ if (aSize.Width()==0 || aSize.Height()==0)
+ return;
+
+ // Remember the new position and size.
+ maViewPos = Point(0,0); //mpParentWindow->GetPosPixel();
+ maViewSize = aSize;
+
+ // Rearrange the UI elements to take care of the new position and size.
+ ArrangeGUIElements ();
+ // end of included AdjustPosSizePixel.
+
+ Size aS (GetParentWindow()->GetOutputSizePixel());
+ Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
+ Rectangle aVisArea = GetParentWindow()->PixelToLogic(
+ Rectangle( Point(0,0), aVisSizePixel));
+ Rectangle aCurrentVisArea (GetDocSh()->GetVisArea(ASPECT_CONTENT));
+ Rectangle aWindowRect = GetActiveWindow()->LogicToPixel(aCurrentVisArea);
+ if (GetDocSh()->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED
+ && IsMainViewShell())
+ {
+ // GetDocSh()->SetVisArea(aVisArea);
+ }
+
+ // VisAreaChanged(aVisArea);
+
+ ::sd::View* pView = GetView();
+
+ if (pView)
+ {
+ pView->VisAreaChanged(GetActiveWindow());
+ }
+}
+
+SvBorder ViewShell::GetBorder (bool )
+{
+ SvBorder aBorder;
+
+ // Horizontal scrollbar.
+ if (mpHorizontalScrollBar.get()!=NULL
+ && mpHorizontalScrollBar->IsVisible())
+ {
+ aBorder.Bottom() = maScrBarWH.Height();
+ }
+
+ // Vertical scrollbar.
+ if (mpVerticalScrollBar.get()!=NULL
+ && mpVerticalScrollBar->IsVisible())
+ {
+ aBorder.Right() = maScrBarWH.Width();
+ }
+
+ // Place horizontal ruler below tab bar.
+ if (mbHasRulers && mpContentWindow.get() != NULL)
+ {
+ SetupRulers();
+ if (mpHorizontalRuler.get() != NULL)
+ aBorder.Top() = mpHorizontalRuler->GetSizePixel().Height();
+ if (mpVerticalRuler.get() != NULL)
+ aBorder.Left() = mpVerticalRuler->GetSizePixel().Width();
+ }
+
+ return aBorder;
+}
+
+
+
+
+void ViewShell::ArrangeGUIElements (void)
+{
+ if (mpImpl->mbArrangeActive)
+ return;
+ mpImpl->mbArrangeActive = true;
+
+ // Calculate border for in-place editing.
+ long nLeft = maViewPos.X();
+ long nTop = maViewPos.Y();
+ long nRight = maViewPos.X() + maViewSize.Width();
+ long nBottom = maViewPos.Y() + maViewSize.Height();
+
+ // Horizontal scrollbar.
+ if (mpHorizontalScrollBar.get()!=NULL
+ && mpHorizontalScrollBar->IsVisible())
+ {
+ int nLocalLeft = nLeft;
+ if (mpLayerTabBar.get()!=NULL && mpLayerTabBar->IsVisible())
+ nLocalLeft += mpLayerTabBar->GetSizePixel().Width();
+ nBottom -= maScrBarWH.Height();
+ mpHorizontalScrollBar->SetPosSizePixel (
+ Point(nLocalLeft,nBottom),
+ Size(nRight-nLocalLeft-maScrBarWH.Width(),maScrBarWH.Height()));
+ }
+
+ // Vertical scrollbar.
+ if (mpVerticalScrollBar.get()!=NULL
+ && mpVerticalScrollBar->IsVisible())
+ {
+ nRight -= maScrBarWH.Width();
+ mpVerticalScrollBar->SetPosSizePixel (
+ Point(nRight,nTop),
+ Size (maScrBarWH.Width(),nBottom-nTop));
+ }
+
+ // Filler in the lower right corner.
+ if (mpScrollBarBox.get() != NULL)
+ {
+ if (mpHorizontalScrollBar.get()!=NULL
+ && mpHorizontalScrollBar->IsVisible()
+ && mpVerticalScrollBar.get()!=NULL
+ && mpVerticalScrollBar->IsVisible())
+ {
+ mpScrollBarBox->Show();
+ mpScrollBarBox->SetPosSizePixel(Point(nRight, nBottom), maScrBarWH);
+ }
+ else
+ mpScrollBarBox->Hide();
+ }
+
+ // Place horizontal ruler below tab bar.
+ if (mbHasRulers && mpContentWindow.get() != NULL)
+ {
+ if (mpHorizontalRuler.get() != NULL)
+ {
+ Size aRulerSize = mpHorizontalRuler->GetSizePixel();
+ aRulerSize.Width() = nRight - nLeft;
+ mpHorizontalRuler->SetPosSizePixel (
+ Point(nLeft,nTop), aRulerSize);
+ if (mpVerticalRuler.get() != NULL)
+ mpHorizontalRuler->SetBorderPos(
+ mpVerticalRuler->GetSizePixel().Width()-1);
+ nTop += aRulerSize.Height();
+ }
+ if (mpVerticalRuler.get() != NULL)
+ {
+ Size aRulerSize = mpVerticalRuler->GetSizePixel();
+ aRulerSize.Height() = nBottom - nTop;
+ mpVerticalRuler->SetPosSizePixel (
+ Point (nLeft,nTop), aRulerSize);
+ nLeft += aRulerSize.Width();
+ }
+ }
+
+ rtl::Reference< SlideShow > xSlideShow( SlideShow::GetSlideShow( GetViewShellBase() ) );
+
+ // The size of the window of the center pane is set differently from
+ // that of the windows in the docking windows.
+ bool bSlideShowActive = (xSlideShow.is() && xSlideShow->isRunning()) && !xSlideShow->isFullScreen() && xSlideShow->getAnimationMode() == ANIMATIONMODE_SHOW;
+ if ( !bSlideShowActive)
+ {
+ OSL_ASSERT (GetViewShell()!=NULL);
+
+ mpContentWindow->SetPosSizePixel(
+ Point(nLeft,nTop),
+ Size(nRight-nLeft,nBottom-nTop));
+ }
+
+ // Windows in the center and rulers at the left and top side.
+ maAllWindowRectangle = Rectangle(
+ maViewPos,
+ Size(maViewSize.Width()-maScrBarWH.Width(),
+ maViewSize.Height()-maScrBarWH.Height()));
+
+ if (mpContentWindow.get() != NULL)
+ {
+ mpContentWindow->UpdateMapOrigin();
+ }
+
+ UpdateScrollBars();
+
+ mpImpl->mbArrangeActive = false;
+}
+
+
+
+
+void ViewShell::SetUIUnit(FieldUnit eUnit)
+{
+ // Set unit at horizontal and vertical rulers.
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->SetUnit(eUnit);
+
+
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->SetUnit(eUnit);
+}
+
+/*************************************************************************
+|*
+|* DefTab an den horizontalen Linealen setzen
+|*
+\************************************************************************/
+void ViewShell::SetDefTabHRuler( sal_uInt16 nDefTab )
+{
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->SetDefTabDist( nDefTab );
+}
+
+
+
+
+/** Tell the FmFormShell that the view shell is closing. Give it the
+ oportunity to prevent that.
+*/
+sal_uInt16 ViewShell::PrepareClose (sal_Bool bUI, sal_Bool bForBrowsing)
+{
+ sal_uInt16 nResult = sal_True;
+
+ FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
+ if (pFormShell != NULL)
+ nResult = pFormShell->PrepareClose (bUI, bForBrowsing);
+
+ return nResult;
+}
+
+
+
+
+void ViewShell::UpdatePreview (SdPage*, sal_Bool )
+{
+ // Do nothing. After the actual preview has been removed,
+ // OutlineViewShell::UpdatePreview() is the place where something
+ // usefull is still done.
+}
+
+::svl::IUndoManager* ViewShell::ImpGetUndoManager (void) const
+{
+ const ViewShell* pMainViewShell = GetViewShellBase().GetMainViewShell().get();
+
+ if( pMainViewShell == 0 )
+ pMainViewShell = this;
+
+ ::sd::View* pView = pMainViewShell->GetView();
+
+ // check for text edit our outline view
+ if( pView )
+ {
+ if( pMainViewShell->GetShellType() == ViewShell::ST_OUTLINE )
+ {
+ OutlineView* pOlView = dynamic_cast< OutlineView* >( pView );
+ if( pOlView )
+ {
+ ::Outliner* pOutl = pOlView->GetOutliner();
+ if( pOutl )
+ return &pOutl->GetUndoManager();
+ }
+ }
+ else if( pView->IsTextEdit() )
+ {
+ SdrOutliner* pOL = pView->GetTextEditOutliner();
+ if( pOL )
+ return &pOL->GetUndoManager();
+ }
+ }
+
+ if( GetDocSh() )
+ return GetDocSh()->GetUndoManager();
+
+ return NULL;
+}
+
+
+
+
+void ViewShell::ImpGetUndoStrings(SfxItemSet &rSet) const
+{
+ ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
+ if(pUndoManager)
+ {
+ sal_uInt16 nCount(pUndoManager->GetUndoActionCount());
+ if(nCount)
+ {
+ // prepare list
+ List aStringList;
+ sal_uInt16 a;
+
+ for( a = 0; a < nCount; a++)
+ {
+ // generate one String in list per undo step
+ String* pInsertString = new String(pUndoManager->GetUndoActionComment(a));
+ aStringList.Insert(pInsertString, LIST_APPEND);
+ }
+
+ // set item
+ rSet.Put(SfxStringListItem(SID_GETUNDOSTRINGS, &aStringList));
+
+ // delete Strings again
+ for(a = 0; a < nCount; a++)
+ delete (String*)aStringList.GetObject(a);
+ }
+ else
+ {
+ rSet.DisableItem(SID_GETUNDOSTRINGS);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void ViewShell::ImpGetRedoStrings(SfxItemSet &rSet) const
+{
+ ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
+ if(pUndoManager)
+ {
+ sal_uInt16 nCount(pUndoManager->GetRedoActionCount());
+ if(nCount)
+ {
+ // prepare list
+ List aStringList;
+ sal_uInt16 a;
+
+ for( a = 0; a < nCount; a++)
+ {
+ // generate one String in list per undo step
+ String* pInsertString = new String(pUndoManager->GetRedoActionComment(a));
+ aStringList.Insert(pInsertString, LIST_APPEND);
+ }
+
+ // set item
+ rSet.Put(SfxStringListItem(SID_GETREDOSTRINGS, &aStringList));
+
+ // delete Strings again
+ for(a = 0; a < nCount; a++)
+ delete (String*)aStringList.GetObject(a);
+ }
+ else
+ {
+ rSet.DisableItem(SID_GETREDOSTRINGS);
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void ViewShell::ImpSidUndo(sal_Bool, SfxRequest& rReq)
+{
+ ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
+ sal_uInt16 nNumber(1);
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ if(pReqArgs)
+ {
+ SfxUInt16Item* pUIntItem = (SfxUInt16Item*)&pReqArgs->Get(SID_UNDO);
+ nNumber = pUIntItem->GetValue();
+ }
+
+ if(nNumber && pUndoManager)
+ {
+ sal_uInt16 nCount(pUndoManager->GetUndoActionCount());
+ if(nCount >= nNumber)
+ {
+ try
+ {
+ // #94637# when UndoStack is cleared by ModifyPageUndoAction
+ // the nCount may have changed, so test GetUndoActionCount()
+ while(nNumber-- && pUndoManager->GetUndoActionCount())
+ {
+ pUndoManager->Undo();
+ }
+ }
+ catch( const Exception& e )
+ {
+ // no need to handle. By definition, the UndoManager handled this by clearing the
+ // Undo/Redo stacks
+ }
+ }
+
+ // #91081# refresh rulers, maybe UNDO was move of TAB marker in ruler
+ if (mbHasRulers)
+ {
+ Invalidate(SID_ATTR_TABSTOP);
+ }
+ }
+
+ // This one is corresponding to the default handling
+ // of SID_UNDO in sfx2
+ GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+
+ rReq.Done();
+}
+
+// -----------------------------------------------------------------------------
+
+void ViewShell::ImpSidRedo(sal_Bool, SfxRequest& rReq)
+{
+ ::svl::IUndoManager* pUndoManager = ImpGetUndoManager();
+ sal_uInt16 nNumber(1);
+ const SfxItemSet* pReqArgs = rReq.GetArgs();
+
+ if(pReqArgs)
+ {
+ SfxUInt16Item* pUIntItem = (SfxUInt16Item*)&pReqArgs->Get(SID_REDO);
+ nNumber = pUIntItem->GetValue();
+ }
+
+ if(nNumber && pUndoManager)
+ {
+ sal_uInt16 nCount(pUndoManager->GetRedoActionCount());
+ if(nCount >= nNumber)
+ {
+ try
+ {
+ // #94637# when UndoStack is cleared by ModifyPageRedoAction
+ // the nCount may have changed, so test GetRedoActionCount()
+ while(nNumber-- && pUndoManager->GetRedoActionCount())
+ {
+ pUndoManager->Redo();
+ }
+ }
+ catch( const Exception& e )
+ {
+ // no need to handle. By definition, the UndoManager handled this by clearing the
+ // Undo/Redo stacks
+ }
+ }
+
+ // #91081# refresh rulers, maybe REDO was move of TAB marker in ruler
+ if (mbHasRulers)
+ {
+ Invalidate(SID_ATTR_TABSTOP);
+ }
+ }
+
+ // This one is corresponding to the default handling
+ // of SID_UNDO in sfx2
+ GetViewFrame()->GetBindings().InvalidateAll(sal_False);
+
+ rReq.Done();
+}
+
+// -----------------------------------------------------------------------------
+
+void ViewShell::ExecReq( SfxRequest& rReq )
+{
+ sal_uInt16 nSlot = rReq.GetSlot();
+ switch( nSlot )
+ {
+ case SID_MAIL_SCROLLBODY_PAGEDOWN:
+ {
+ FunctionReference xFunc( GetCurrentFunction() );
+ if( xFunc.is() )
+ {
+ xFunc->ScrollStart();
+ ScrollLines( 0, -1 );
+ xFunc->ScrollEnd();
+ }
+
+ rReq.Done();
+ }
+ break;
+
+ case SID_OUTPUT_QUALITY_COLOR:
+ case SID_OUTPUT_QUALITY_GRAYSCALE:
+ case SID_OUTPUT_QUALITY_BLACKWHITE:
+ case SID_OUTPUT_QUALITY_CONTRAST:
+ {
+ sal_uLong nMode = OUTPUT_DRAWMODE_COLOR;
+
+ switch( nSlot )
+ {
+ case SID_OUTPUT_QUALITY_COLOR: nMode = OUTPUT_DRAWMODE_COLOR; break;
+ case SID_OUTPUT_QUALITY_GRAYSCALE: nMode = OUTPUT_DRAWMODE_GRAYSCALE; break;
+ case SID_OUTPUT_QUALITY_BLACKWHITE: nMode = OUTPUT_DRAWMODE_BLACKWHITE; break;
+ case SID_OUTPUT_QUALITY_CONTRAST: nMode = OUTPUT_DRAWMODE_CONTRAST; break;
+ }
+
+ GetActiveWindow()->SetDrawMode( nMode );
+ mpFrameView->SetDrawMode( nMode );
+// #110094#-7
+// GetView()->ReleaseMasterPagePaintCache();
+ GetActiveWindow()->Invalidate();
+
+ Invalidate();
+ rReq.Done();
+ break;
+ }
+ }
+}
+
+
+
+
+/** This default implemenation returns only an empty reference. See derived
+ classes for more interesting examples.
+*/
+::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible>
+ViewShell::CreateAccessibleDocumentView (::sd::Window* )
+{
+ return ::com::sun::star::uno::Reference<
+ ::com::sun::star::accessibility::XAccessible> ();
+}
+
+
+
+::sd::WindowUpdater* ViewShell::GetWindowUpdater (void) const
+{
+ return mpWindowUpdater.get();
+}
+
+
+
+
+ViewShellBase& ViewShell::GetViewShellBase (void) const
+{
+ return *static_cast<ViewShellBase*>(GetViewShell());
+}
+
+
+
+
+ViewShell::ShellType ViewShell::GetShellType (void) const
+{
+ return meShellType;
+}
+
+
+
+
+DrawDocShell* ViewShell::GetDocSh (void) const
+{
+ return GetViewShellBase().GetDocShell();
+}
+
+
+
+
+SdDrawDocument* ViewShell::GetDoc (void) const
+{
+ return GetViewShellBase().GetDocument();
+}
+
+ErrCode ViewShell::DoVerb (long )
+{
+ return ERRCODE_NONE;
+}
+
+void ViewShell::SetCurrentFunction( const FunctionReference& xFunction)
+{
+ if( mxCurrentFunction.is() && (mxOldFunction != mxCurrentFunction) )
+ mxCurrentFunction->Dispose();
+ FunctionReference xTemp( mxCurrentFunction );
+ mxCurrentFunction = xFunction;
+}
+
+void ViewShell::SetOldFunction(const FunctionReference& xFunction)
+{
+ if( mxOldFunction.is() && (xFunction != mxOldFunction) && (mxCurrentFunction != mxOldFunction) )
+ mxOldFunction->Dispose();
+
+ FunctionReference xTemp( mxOldFunction );
+ mxOldFunction = xFunction;
+}
+
+/** this method deactivates the current function. If an old function is
+ saved, this will become activated and current function.
+*/
+void ViewShell::Cancel()
+{
+ if(mxCurrentFunction.is() && (mxCurrentFunction != mxOldFunction ))
+ {
+ FunctionReference xTemp( mxCurrentFunction );
+ mxCurrentFunction.clear();
+ xTemp->Deactivate();
+ xTemp->Dispose();
+ }
+
+ if(mxOldFunction.is())
+ {
+ mxCurrentFunction = mxOldFunction;
+ mxCurrentFunction->Activate();
+ }
+}
+
+void ViewShell::DeactivateCurrentFunction( bool bPermanent /* == false */ )
+{
+ if( mxCurrentFunction.is() )
+ {
+ if(bPermanent && (mxOldFunction == mxCurrentFunction))
+ mxOldFunction.clear();
+
+ mxCurrentFunction->Deactivate();
+ if( mxCurrentFunction != mxOldFunction )
+ mxCurrentFunction->Dispose();
+
+ FunctionReference xTemp( mxCurrentFunction );
+ mxCurrentFunction.clear();
+ }
+}
+
+void ViewShell::DisposeFunctions()
+{
+ if(mxCurrentFunction.is())
+ {
+ FunctionReference xTemp( mxCurrentFunction );
+ mxCurrentFunction.clear();
+ xTemp->Deactivate();
+ xTemp->Dispose();
+ }
+
+ if(mxOldFunction.is())
+ {
+ FunctionReference xTemp( mxOldFunction );
+ mxOldFunction->Dispose();
+ mxOldFunction.clear();
+ }
+}
+
+bool ViewShell::IsMainViewShell (void) const
+{
+ return mpImpl->mbIsMainViewShell;
+ // return GetViewShellBase().GetMainViewShell() == this;
+}
+
+void ViewShell::SetIsMainViewShell (bool bIsMainViewShell)
+{
+ if (bIsMainViewShell != mpImpl->mbIsMainViewShell)
+ {
+ mpImpl->mbIsMainViewShell = bIsMainViewShell;
+ if (bIsMainViewShell)
+ {
+ GetDocSh()->Connect (this);
+ }
+ else
+ {
+ GetDocSh()->Disconnect (this);
+ }
+ }
+}
+
+
+
+
+::sd::Window* ViewShell::GetActiveWindow (void) const
+{
+ return mpActiveWindow;
+}
+
+
+
+
+void ViewShell::PrePaint()
+{
+}
+
+
+
+
+void ViewShell::Paint (const Rectangle&, ::sd::Window* )
+{
+}
+
+
+
+
+void ViewShell::Draw(OutputDevice &, const Region &)
+{
+}
+
+
+
+
+ZoomList* ViewShell::GetZoomList (void)
+{
+ return mpZoomList;
+}
+
+
+
+
+void ViewShell::ShowUIControls (bool bVisible)
+{
+ mpImpl->mbIsShowingUIControls = bVisible;
+
+ if (mbHasRulers)
+ {
+ if (mpHorizontalRuler.get() != NULL)
+ mpHorizontalRuler->Show( bVisible );
+
+ if (mpVerticalRuler.get() != NULL)
+ mpVerticalRuler->Show( bVisible );
+ }
+
+ if (mpVerticalScrollBar.get() != NULL)
+ mpVerticalScrollBar->Show( bVisible );
+
+ if (mpHorizontalScrollBar.get() != NULL)
+ mpHorizontalScrollBar->Show( bVisible );
+
+ if (mpScrollBarBox.get() != NULL)
+ mpScrollBarBox->Show(bVisible);
+
+ if (mpContentWindow.get() != NULL)
+ mpContentWindow->Show( bVisible );
+}
+
+
+
+
+
+bool ViewShell::RelocateToParentWindow (::Window* pParentWindow)
+{
+ mpParentWindow = pParentWindow;
+
+ mpParentWindow->SetBackground (Wallpaper());
+
+ if (mpContentWindow.get() != NULL)
+ mpContentWindow->SetParent(pParentWindow);
+
+ if (mpHorizontalScrollBar.get() != NULL)
+ mpHorizontalScrollBar->SetParent(mpParentWindow);
+ if (mpVerticalScrollBar.get() != NULL)
+ mpVerticalScrollBar->SetParent(mpParentWindow);
+ if (mpScrollBarBox.get() != NULL)
+ mpScrollBarBox->SetParent(mpParentWindow);
+
+ return true;
+}
+
+
+
+} // end of namespace sd
+
+
+
+
+
+//===== ViewShellObjectBarFactory =============================================
+
+namespace {
+
+ViewShellObjectBarFactory::ViewShellObjectBarFactory (
+ ::sd::ViewShell& rViewShell)
+ : mrViewShell (rViewShell)
+{
+}
+
+
+
+
+ViewShellObjectBarFactory::~ViewShellObjectBarFactory (void)
+{
+ for (ShellCache::iterator aI(maShellCache.begin());
+ aI!=maShellCache.end();
+ aI++)
+ {
+ delete aI->second;
+ }
+}
+
+
+
+
+SfxShell* ViewShellObjectBarFactory::CreateShell (
+ ::sd::ShellId nId,
+ ::Window*,
+ ::sd::FrameView* )
+{
+ SfxShell* pShell = NULL;
+
+ ShellCache::iterator aI (maShellCache.find(nId));
+ if (aI == maShellCache.end() || aI->second==NULL)
+ {
+ ::sd::View* pView = mrViewShell.GetView();
+ switch (nId)
+ {
+ case RID_BEZIER_TOOLBOX:
+ pShell = new ::sd::BezierObjectBar(&mrViewShell, pView);
+ break;
+
+ case RID_DRAW_TEXT_TOOLBOX:
+ pShell = new ::sd::TextObjectBar(
+ &mrViewShell, mrViewShell.GetDoc()->GetPool(), pView);
+ break;
+
+ case RID_DRAW_GRAF_TOOLBOX:
+ pShell = new ::sd::GraphicObjectBar(&mrViewShell, pView);
+ break;
+
+ case RID_DRAW_MEDIA_TOOLBOX:
+ pShell = new ::sd::MediaObjectBar(&mrViewShell, pView);
+ break;
+
+ case RID_DRAW_TABLE_TOOLBOX:
+ pShell = ::sd::ui::table::CreateTableObjectBar( mrViewShell, pView );
+ break;
+
+ case RID_SVX_EXTRUSION_BAR:
+ pShell = new ::svx::ExtrusionBar(
+ &mrViewShell.GetViewShellBase());
+ break;
+
+ case RID_SVX_FONTWORK_BAR:
+ pShell = new ::svx::FontworkBar(
+ &mrViewShell.GetViewShellBase());
+ break;
+
+ default:
+ pShell = NULL;
+ break;
+ }
+ }
+ else
+ pShell = aI->second;
+
+ return pShell;
+}
+
+
+
+
+void ViewShellObjectBarFactory::ReleaseShell (SfxShell* pShell)
+{
+ if (pShell != NULL)
+ delete pShell;
+}
+
+} // end of anonymous namespace
diff --git a/sd/source/ui/view/zoomlist.cxx b/sd/source/ui/view/zoomlist.cxx
new file mode 100755
index 000000000000..97932bc15033
--- /dev/null
+++ b/sd/source/ui/view/zoomlist.cxx
@@ -0,0 +1,197 @@
+/*************************************************************************
+ *
+ * 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 "zoomlist.hxx"
+
+#ifndef _SVXIDS_HRC
+#include <svx/svxids.hrc>
+#endif
+#include <sfx2/bindings.hxx>
+#include <sfx2/viewfrm.hxx>
+#ifndef _SFXVIEWSHELL_HXX
+#include <sfx2/viewsh.hxx>
+#endif
+
+
+#include "ViewShell.hxx"
+
+namespace sd {
+
+#define MAX_ENTRYS 10
+
+/*************************************************************************
+|*
+|* Konstruktor
+|*
+\************************************************************************/
+
+ZoomList::ZoomList(ViewShell* pViewShell)
+: List()
+, mpViewShell (pViewShell)
+, mnCurPos(0)
+{
+}
+
+
+/*************************************************************************
+|*
+|* Destruktor
+|*
+\************************************************************************/
+
+ZoomList::~ZoomList()
+{
+#if ( defined GCC && defined C272 )
+ for (sal_uLong nObject=0; nObject<List::Count(); nObject++)
+#else
+ for (sal_uLong nObject=0; nObject<Count(); nObject++)
+#endif
+ {
+ // Ggf. ZoomRects loeschen
+ delete ((Rectangle*) GetObject(nObject));
+ }
+}
+
+
+/*************************************************************************
+|*
+|* Neues ZoomRect aufnehmen
+|*
+\************************************************************************/
+
+void ZoomList::InsertZoomRect(const Rectangle& rRect)
+{
+ sal_uLong nRectCount = Count();
+
+ if (nRectCount >= MAX_ENTRYS)
+ {
+ delete ((Rectangle*) GetObject(0));
+ Remove((sal_uLong) 0);
+ }
+ else if (nRectCount == 0)
+ {
+ mnCurPos = 0;
+ }
+ else
+ {
+ mnCurPos++;
+ }
+
+ Rectangle* pRect = new Rectangle(rRect);
+ Insert(pRect, mnCurPos);
+
+ SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_ZOOM_NEXT );
+ rBindings.Invalidate( SID_ZOOM_PREV );
+}
+
+/*************************************************************************
+|*
+|* Naechstes ZoomRect herausgeben
+|*
+\************************************************************************/
+
+Rectangle ZoomList::GetNextZoomRect()
+{
+ mnCurPos++;
+ sal_uLong nRectCount = Count();
+
+ if (nRectCount > 0 && mnCurPos > nRectCount - 1)
+ {
+ mnCurPos = nRectCount - 1;
+ }
+
+ SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_ZOOM_NEXT );
+ rBindings.Invalidate( SID_ZOOM_PREV );
+
+ Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
+ return (aRect);
+}
+
+/*************************************************************************
+|*
+|* Letztes ZoomRect herausgeben
+|*
+\************************************************************************/
+
+Rectangle ZoomList::GetPreviousZoomRect()
+{
+ if (mnCurPos > 0)
+ {
+ mnCurPos--;
+ }
+
+ SfxBindings& rBindings = mpViewShell->GetViewFrame()->GetBindings();
+ rBindings.Invalidate( SID_ZOOM_NEXT );
+ rBindings.Invalidate( SID_ZOOM_PREV );
+
+ Rectangle aRect(*(Rectangle*) GetObject(mnCurPos));
+ return (aRect);
+}
+
+/*************************************************************************
+|*
+|* Gibt es ein naechstes ZoomRect?
+|*
+\************************************************************************/
+
+sal_Bool ZoomList::IsNextPossible() const
+{
+ sal_Bool bPossible = sal_False;
+ sal_uLong nRectCount = Count();
+
+ if (nRectCount > 0 && mnCurPos < nRectCount - 1)
+ {
+ bPossible = sal_True;
+ }
+
+ return (bPossible);
+}
+
+/*************************************************************************
+|*
+|* Gibt es ein vorheriges ZoomRect?
+|*
+\************************************************************************/
+
+sal_Bool ZoomList::IsPreviousPossible() const
+{
+ sal_Bool bPossible = sal_False;
+
+ if (mnCurPos > 0)
+ {
+ bPossible = sal_True;
+ }
+
+ return (bPossible);
+}
+
+} // end of namespace sd