[ooo-build-commit] patches/dev300
Radek DoulÃk
rodo at kemper.freedesktop.org
Fri Aug 7 05:45:43 PDT 2009
patches/dev300/sd-layoutcode.diff | 2291 +++++++++++++++++++++++++++++++-------
1 file changed, 1908 insertions(+), 383 deletions(-)
New commits:
commit f200e9eb4f9b00bac139121e35b199d326010661
Author: Dona Hertel <cocofan at mailbolt.com>
Date: Tue Aug 4 23:48:22 2009 -0700
fixed some bugs and added comments
* patches/dev300/sd-layoutcode.diff:
diff --git a/patches/dev300/sd-layoutcode.diff b/patches/dev300/sd-layoutcode.diff
index 4919aa6..4b59efc 100644
--- a/patches/dev300/sd-layoutcode.diff
+++ b/patches/dev300/sd-layoutcode.diff
@@ -48,8 +48,8 @@ diff -Nrup sd-m16/inc/drawdoc.hxx sd/inc/drawdoc.hxx
diff -Nrup sd-m16/inc/layoutlist.hxx sd/inc/layoutlist.hxx
--- sd-m16/inc/layoutlist.hxx 1969-12-31 16:00:00.000000000 -0800
-+++ sd/inc/layoutlist.hxx 2009-08-02 21:57:23.000000000 -0700
-@@ -0,0 +1,270 @@
++++ sd/inc/layoutlist.hxx 2009-08-04 21:28:03.000000000 -0700
+@@ -0,0 +1,338 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -168,98 +168,135 @@ diff -Nrup sd-m16/inc/layoutlist.hxx sd/inc/layoutlist.hxx
+ LayoutList(bool testing=false);
+ ~LayoutList();
+
-+ /** passes back the absolute path plus file name
-+ * of the autolayout configuration file.
-+ */
++ /** Passes back the path with file name for the configuration
++ * file where autolayout information is stored.
++ */
+ String* getConfigFile();
+
-+ /** write entire layout information to a config file
++ /** This writes the autolayout information (the layout list and
++ * all menu lists) to the configuration file. Also, see LayoutType
++ * class for the writing of each layout's information to the file.
+ */
+ void writeToFile();
+
+
-+ /** read entire layout information to a config file
++ /** This reads the autolayout information (the layout list and
++ * all menu lists) in from the configuration file. Also, see LayoutType
++ * class for the reading of each layout's information from the file.
+ */
+ void readFromFile();
+
-+ /** adds a layout object to the list
-+ * passes back a true if the layout
-+ * was successfully added and passes back
-+ * a false if not (name already in the list,
-+ * for example). Also, adds to the given
-+ * menu list at the given index (or at
-+ * the end if the index is negative(-1)) */
-+ bool addLayout(LayoutType* pLayout, const sal_Int32& menuIndex,
++ /** adds new layouts to the layoutlist and the menu order list.
++ * params: pLayout - pointer to the new layout
++ * menuIndex - the menu order index at
++ * which the new layout is
++ * inserted. If -1, it will
++ * be inserted at the end.
++ * eMenu - which menu to put it in.
++ * (PK_STANDARD, PK_NOTES or
++ * PK_HANDOUT)
++ * passes back the index in the autolayout list or -1 if it
++ * was not successfully inserted.
++ */
++
++ sal_Int32 addLayout(LayoutType* pLayout, const sal_Int32& menuIndex,
+ const PageKind& eMenu);
+
-+ /** removes a custom layout from the layout list
-+ * but doesn't remove builtins.
-+ * Deletes the layout object and sets a NULL
-+ * in the layout list so as not to change the
-+ * indices of the list. It also finds the menu
-+ * entry and removes it completely. Items will
-+ * be moved up in the menu list.
-+ */
++ /** deletes custom layouts to the layoutlist and the menu order list.\
++ * Since there are places where builtin layouts are needed, it will
++ * not delete builtins from the layoutlist, just delete them from
++ * the menu order lists.
++ *
++ * param: sName - name of layout to delete
++ *
++ */
+ void deleteLayoutFromList(const LString& sName);
+
-+ /** return the length of the list. This may not be
-+ * the number of actual layouts in the list */
++ /** returns length of layout list. This
++ * may not be the number of actual layouts
++ * If some layouts are deleted, the list
++ * doesn't shrink in size. Use numberOfLayouts
++ * for a count of layouts and length to iterate
++ * through the layout list.
++ */
+ sal_uInt32 length() const;
+
-+ /** return the number of actual layouts in the list
++ /** number of actual layouts in the list. This is not
++ * the length (or number of elements) in the list
++ * itself. Use length() for iterating the list.
+ */
+ sal_uInt32 numberOfLayouts() const;
+
-+ /** pass in the index to the list. for iterating
-+ * the list. Will send back a NULL if a layout isn't there.
-+ */
++ /** Gets the layout object at the given index into the layout list.
++ * returns a NULL if the given index is out of range.
++ */
+ LayoutType* getLayoutByIndex(const sal_uInt32 nIndex);
+
-+
-+
-+ /** find and pass back a layout object with the given
-+ name or NULL */
++ /** gets the layout object with the given name. Returns
++ * NULL if the name can't be found in the layout list.
++ */
+ LayoutType* getLayoutByName(const LString& sName);
+
-+ /** get the autolayout value of the given name. It will
-+ * send back a LL_NOT_FOUND if there is no layout. Need to
-+ * cast this value to a sal_uInt32 to use as an
-+ * index into the list. */
++ /** passes back the index into the layout list with a given name.
++ * Passes back LL_NOT_FOUND if the name is not in the list.
++ */
+ sal_uInt32 getLayoutIndex(const LString& sName);
+
-+ /** get the layout object for the given layoutMenu
-+ * index.
-+ */
++ /** passes back the layout object associated with the (nIndex)th entry
++ * into the menu. Passes back a NULL if nIndex is out of range, not
++ * a valid menu type, or the layout doesn't exist.
++ */
+ LayoutType* getLayoutAtMenuIndex(const sal_uInt32& nIndex,
+ const PageKind& eMenu);
+
-+ /** get the size of a particular menu list */
++ /** passes back the length of the given menu order list.
++ * Passes back a zero if given an invalid menu type.
++ */
+ sal_uInt32 getMenuLength(const PageKind& eMenu);
+
-+ /** given an autolayout number, find the index in the menu.
-+ * If not in the list, then passes back LL_NOT_FOUND*/
++ /** Gets the menu order index for a given layout list index. Passes
++ * back LL_NOT_FOUND if can't find layout or not a valid menu list */
+ sal_uInt32 getMenuIndex(const AutoLayout& nLayout,
+ const PageKind& nMenu);
-+
-+ /** remove the autolayout from the list. Need to move
-+ * the layouts over.
-+ */
++
++
++
++ /** removes a given layout's index from the menu order list.
++ * Doesn't delete from the layout list. Uses 'erase' so
++ * the indices after the deleted layout are moved up one
++ * in the list.
++ */
+ void removeFromMenuList(const AutoLayout& lnum,
+ const PageKind& eMenu);
+
-+ /** add an autolayout to the menu list. will grow
-+ * the list to fit the given index. A negative index
-+ * will cause the autolayout to be appended to the
-+ * end of the list. */
-+
++ /** Adds a layout (or it's index in the layout list) to
++ * a given menu order list at the given index. If the
++ * given menu index is out of range (less than zero or
++ * larger than the list), the layout number is pushed on
++ * the end of the menu list.
++ */
+ void addToMenuList(const sal_Int32& index,
+ const AutoLayout& lnum,
+ const PageKind& eMenu);
+
++
++ /** moves the place in the Layout menu for a particular layout
++ * removes it's index in the list and then re-adds it according
++ * to the passed-in menu index.
++ */
++ void moveLayoutInMenu(const sal_Int32& nMenuIdx,
++ const AutoLayout& nIndex,
++ const PageKind& eMenu);
+
+ /** UNO implementation of interface XLayoutList
+ * for use with xmloff code
+ */
++
++
++ /** passes back the bounding rectangles for a layout at a given
++ * index in the layout list.
++ * for use with xmloff code.
++ */
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::awt::Rectangle >
+ SAL_CALL getAutoLayoutRectangles( ::sal_Int32 Index,
+ const ::com::sun::star::awt::Rectangle& title,
@@ -271,23 +308,33 @@ diff -Nrup sd-m16/inc/layoutlist.hxx sd/inc/layoutlist.hxx
+ ::com::sun::star::awt::Rectangle RectToUNORect(const Rectangle& rect);
+
+
-+ /** UNO implementation for getting the Page Kind of a layout
-+ * and the PresObjKind of an element in a layout
++ /** gets the page kind of a given layout at an given index
++ * Used with xmloff code.
+ */
+ virtual ::com::sun::star::presentation::UnoPageKind SAL_CALL getPageKind( ::sal_Int32 Index )
+ throw (::com::sun::star::uno::RuntimeException);
+
-+
++ /** gets the number of elements (presentation objects) for a given
++ * index of a layout.
++ * Used by the xmloff code.
++ */
+ virtual ::sal_Int32 SAL_CALL getElementCount( ::sal_Int32 Index)
+ throw (::com::sun::star::uno::RuntimeException);
+
++ /** passes back whether the element (with a given index) of the layout
++ * (of a given index) is vertical or not.
++ * Used by the xmloff code.
++ */
++ virtual ::sal_Bool SAL_CALL isVertical( ::sal_Int32 Index, ::sal_Int32 ElemIdx)
++ throw (::com::sun::star::uno::RuntimeException);
++
++ /** passes back the presentation kind of a given element (with a given
++ * index) of a given layout (of a given index).
++ * Used by the xmloff code.
++ */
+ virtual ::com::sun::star::presentation::UnoPresKind SAL_CALL getPresKind( ::sal_Int32 Index,
+ ::sal_Int32 ElemIdx )
+ throw (::com::sun::star::uno::RuntimeException);
-+
-+ virtual ::sal_Bool SAL_CALL isVertical( ::sal_Int32 Index, ::sal_Int32 ElemIdx)
-+ throw (::com::sun::star::uno::RuntimeException);
-+
+
+ private:
+
@@ -307,13 +354,34 @@ diff -Nrup sd-m16/inc/layoutlist.hxx sd/inc/layoutlist.hxx
+
+ bool mbTesting; // used to determine when testing.
+
++ /** These functions are used to initialize the layout list
++ * with builtins if the configuration file doesn't exist.
++ * Probably will be removed at a later date when the
++ * installation has a configuration file to read in.
++ */
++ /** Initializes the layout list with the builtins.
++ */
+ void initializeList();
++ /** puts the builtin layout indices in the menu
++ * order lists.
++ */
+ void initializeMenuOrder();
++
++ /** This is a helper function for writeToFile. It writes one
++ * of the menu order lists to the file.
++ */
+ void writeMenuListToFile(FastSerializerHelper& fsh,
+ MEListImpl& list, const char* sTag);
++
++ /** helper function for reading in a menu order list from the
++ * configuration file.
++ */
+ void readMenuListFromFile(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xml::dom::XNodeList >& nodelist,
+ MEListImpl& list);
++
++
++
+
+ }; // Class LayoutList
+
@@ -322,8 +390,8 @@ diff -Nrup sd-m16/inc/layoutlist.hxx sd/inc/layoutlist.hxx
+#endif // _LAYOUTLIST_HXX
diff -Nrup sd-m16/inc/layouttype.hxx sd/inc/layouttype.hxx
--- sd-m16/inc/layouttype.hxx 1969-12-31 16:00:00.000000000 -0800
-+++ sd/inc/layouttype.hxx 2009-07-31 00:10:16.000000000 -0700
-@@ -0,0 +1,226 @@
++++ sd/inc/layouttype.hxx 2009-08-04 22:53:39.000000000 -0700
+@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -385,18 +453,19 @@ diff -Nrup sd-m16/inc/layouttype.hxx sd/inc/layouttype.hxx
+ * standard rectangle to use
+ * to calculate bounding rects
+ * and also determine the factors
-+ * used to calculate the rects.
++ * used to calculate the custom
++ * rects.
+ */
+
+ enum RectType {
+ RT_TITLE, // a non-vertical title
-+ RT_VERTICAL_TITLE,
++ RT_VERTICAL_TITLE, // a vertical title
+ RT_LAYOUT, // a non-vertical non-title shape
-+ RT_VERTICAL_LAYOUT,
++ RT_VERTICAL_LAYOUT, // a vertical non-title shape
+ RT_TEXT_ONLY, // for the text only layout
+ RT_LAYOUT_SWITCH, // use if shapes need switching
+ // for right to left writing
-+ RT_ERROR
++ RT_MAX
+ };
+
+ /** ElemType defines the information for
@@ -405,17 +474,22 @@ diff -Nrup sd-m16/inc/layouttype.hxx sd/inc/layouttype.hxx
+ */
+
+ typedef struct {
-+ PresObjKind kind; // the type of pres. object
-+ bool isVertical; // whether to make this obj. vertical
-+ double factorX; // factor for calculating topleft x value
-+ double factorY; // factor for calculating topleft y value
-+ double factorHt; // factor for calculating height
-+ double factorWt; // factor for calculating width
-+ RectType recttype; // type of standard rect to use
-+ // for calculating rects.
++ PresObjKind kind; // the type of pres. object
++ bool isVertical; // whether to make this obj. vertical
++ double factorX; // factor for calculating topleft x value
++ // X = Xstandard + WidthStandard*factorX
++ double factorY; // factor for calculating topleft y value
++ // Y = Ystandard + HeightStandard*factorY
++ double factorHt; // factor for calculating height
++ // Height = HeightStandard*factorHt
++ double factorWt; // factor for calculating width
++ // Width = WidthStandard*factorWt
++ RectType recttype; // type of standard rect to use
++ // for calculating rects.
+ } ElemType;
+
-+ /** LayoutType represents on autolayout */
++ /** LayoutType represents the information for one autolayout
++ */
+
+ class LayoutType
+ {
@@ -431,7 +505,7 @@ diff -Nrup sd-m16/inc/layouttype.hxx sd/inc/layouttype.hxx
+ const ElemType* elem);
+
+ /** functions for reading this layout in from a xml configuration
-+ * file. Passes back entry in the list.
++ * file. Passes back index to the layout list.
+ */
+ sal_Int32 getIntValue(const Reference<dom::XNode>& node);
+ double getDoubleValue(const Reference<dom::XNode>& node);
@@ -440,9 +514,8 @@ diff -Nrup sd-m16/inc/layouttype.hxx sd/inc/layouttype.hxx
+ /** get functions for variables
+ * other than elements
+ */
-+
+ LString getName();
-+ sal_uInt32 getStrId();
++ sal_Int32 getStrId();
+ WritingMode getWritingMode();
+ sal_uInt32 getHBitmapId();
+ sal_uInt32 getLBitmapId();
@@ -466,7 +539,7 @@ diff -Nrup sd-m16/inc/layouttype.hxx sd/inc/layouttype.hxx
+ */
+
+ void setName(const LString& sName);
-+ void setStrId(const sal_uInt32 id);
++ void setStrId(const sal_Int32 id);
+ void setWritingMode(const WritingMode& wmode);
+ void setHBitmapId(const sal_uInt32& id);
+ void setLBitmapId(const sal_uInt32& id);
@@ -516,11 +589,8 @@ diff -Nrup sd-m16/inc/layouttype.hxx sd/inc/layouttype.hxx
+ const bool& bRightToLeft,
+ Rectangle* pRectangle );
+
-+ /** initialize the rectInfo. Mainly designed for builtins
-+ * but might be useful for custom layouts.
-+ * Should be called after the elements are
-+ * all in the list, otherwise some elements won't be
-+ * initialized at all.
++ /** initialize the rectInfo for builtin
++ * layout elements.
+ * These functions may not be
+ * needed after the configuration
+ * file code is done. */
@@ -532,13 +602,13 @@ diff -Nrup sd-m16/inc/layouttype.hxx sd/inc/layouttype.hxx
+
+ private:
+ LString name; // String name of the layout
-+ sal_uInt32 nStrId; // resource id for the string.
++ sal_Int32 nStrId; // resource id for the string.
+ WritingMode nWritingMode; // righttoleft or toptobottom
-+ sal_uInt32 nHBitmapId; // resource id for the High Contrast Bitmap
-+ sal_uInt32 nLBitmapId; // resource id for the Low contrast Bitmap
++ sal_uInt32 nHBitmapId; // resource id for the High Contrast? Bitmap
++ sal_uInt32 nLBitmapId; // resource id for the Low contrast? Bitmap
+ PageKind nPageKind; // the page kind for this layout (PK_STANDARD, PK_NOTES, PK_HANDOUT)
+
-+ // list of elements whicht the pres. objects will be
++ // list of elements which the pres. objects will be
+ // created from for this layout.
+ typedef std::vector< ElemType* > ListImpl;
+ ListImpl elemList;
@@ -877,8 +947,8 @@ diff -Nrup sd-m16/source/core/drawdoc.cxx sd/source/core/drawdoc.cxx
/*************************************************************************
diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
--- sd-m16/source/core/layoutlist.cxx 1969-12-31 16:00:00.000000000 -0800
-+++ sd/source/core/layoutlist.cxx 2009-08-02 21:57:24.000000000 -0700
-@@ -0,0 +1,1373 @@
++++ sd/source/core/layoutlist.cxx 2009-08-04 21:28:02.000000000 -0700
+@@ -0,0 +1,1502 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -961,10 +1031,10 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+static char sHandoutTag[] = "MenuHandout";
+static char sNumTag[] = "number";
+
-+LayoutList::LayoutList(bool testing)
++
++LayoutList::LayoutList(bool testing):
++ mbTesting(testing)
+{
-+ mbTesting = testing;
-+
+ maLayoutList.reserve(50);
+ maStandard.reserve(50);
+ maHandout.reserve(50);
@@ -994,7 +1064,7 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ }
+ }
+
-+ // not sure if this is needed:
++ // clear out lists
+ maLayoutList.clear();
+ maStandard.clear();
+ maNotes.clear();
@@ -1026,7 +1096,8 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+}
+
+/** This writes the autolayout information (the layout list and
-+ * all menu lists) to the configuration file.
++ * all menu lists) to the configuration file. Also, see LayoutType
++ * class for the writing of each layout's information to the file.
+ */
+
+void LayoutList::writeToFile()
@@ -1051,7 +1122,7 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ sal_Int32 count = numberOfLayouts();
+ sprintf(sCountValue, "%d", (int) count);
+
-+ //<AutoLayoutInfo><layoutList count="35">
++ //<AutoLayoutInfo><layoutList count="...">
+ fsh.startElement(sTopTag,NULL);
+ fsh.startElement(sLListTag, sCountTag, sCountValue, NULL);
+
@@ -1090,6 +1161,10 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+}
+
++/** This is a helper function for writeToFile. It writes one
++ * of the menu order lists to the file.
++ */
++
+void LayoutList::writeMenuListToFile(FastSerializerHelper& fsh,
+ MEListImpl& list, const char* sTag)
+{
@@ -1108,6 +1183,10 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+}
+
++/** This reads the autolayout information (the layout list and
++ * all menu lists) in from the configuration file. Also, see LayoutType
++ * class for the reading of each layout's information from the file.
++ */
+
+void LayoutList::readFromFile()
+{
@@ -1121,7 +1200,7 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ {
+ OSL_TRACE("readFromFile: Cannot open autolayout config file %s", STRTOCHAR(*psFileName));
+ // For now, we'll create the builtins from code and write the config
-+ // file out.
++ // file out.
+ initializeList();
+ writeToFile();
+ return;
@@ -1167,8 +1246,6 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ // Put into list where indicated
+ maLayoutList[index] = layout;
+ }
-+
-+
+
+ // get the menu order lists
+ // Standard menu list
@@ -1189,12 +1266,17 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+}
+
++/** helper function for reading in a menu order list from the
++ * configuration file.
++ */
++
++
+void LayoutList::readMenuListFromFile(const Reference< XNodeList >& nodelist, MEListImpl& list)
+{
+ sal_Int32 size = nodelist->getLength()-1;
+ sal_Int32 index;
-+ //OSL_TRACE("SIZE OF MENU LIST %d", size);
+
++ //OSL_TRACE("SIZE OF MENU LIST %d", size);
+ list.resize(size, 0);
+
+ // i = 1 because we need to skip 1st tag
@@ -1219,36 +1301,48 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+}
+
-+/** used for adding new custom layouts. */
++/** adds new layouts to the layoutlist and the menu order list.
++ * params: pLayout - pointer to the new layout
++ * menuIndex - the menu order index at
++ * which the new layout is
++ * inserted. If -1, it will
++ * be inserted at the end.
++ * eMenu - which menu to put it in.
++ * (PK_STANDARD, PK_NOTES or
++ * PK_HANDOUT)
++ * passes back the index in the autolayout list or -1 if it
++ * was not successfully inserted.
++ */
+
-+bool LayoutList::addLayout(LayoutType* pLayout,
++sal_Int32 LayoutList::addLayout(LayoutType* pLayout,
+ const sal_Int32& menuIndex, const PageKind& eMenu)
+{
+ LayoutType* layout;
+ sal_Int32 idx;
+ bool bFoundAHole = false;
+
-+ if(!layout) return false;
++ if(!layout) return -1;
+
+ LString name = pLayout->getName();
+ idx = getLayoutIndex(name);
+ if(idx != LL_NOT_FOUND)
+ {
+ //DBG_ERROR("sd::LayoutList::addLayout(), given layout name already part of list!");
-+ return false;
++ return -1;
+ }
+
+ for(sal_uInt32 i = 0; i < length(); i++)
+ {
+ //looking for any places with NULL
+ layout = maLayoutList[i];
-+ if(!layout)
++ if(!layout) // if found, insert here.
+ {
+ bFoundAHole = true;
+ maLayoutList[i] = pLayout;
+ }
+ }
+
++ // if no NULL places inside list
+ if(!bFoundAHole)
+ {
+ // push onto the back of the list
@@ -1257,14 +1351,23 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+ //need to set page kind (eMenu is page kind)
+ pLayout->setPageKind(eMenu);
++
+ //now, find where it was put
+ idx = getLayoutIndex(name);
+ // add this value to the given menu at the given location
+ addToMenuList(menuIndex, (AutoLayout) idx, eMenu);
+
-+ return true;
++ return idx;
+}
-+
++
++/** deletes custom layouts to the layoutlist and the menu order list.\
++ * Since there are places where builtin layouts are needed, it will
++ * not delete builtins from the layoutlist, just delete them from
++ * the menu order lists.
++ *
++ * param: sName - name of layout to delete
++ *
++ */
+
+void LayoutList::deleteLayoutFromList(const LString& sName)
+{
@@ -1281,26 +1384,44 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ // Since the indices will change if
+ // I use erase (the items get move up
+ // by one) and I don't want to reorder
-+ // the list. So I'll just, set the space to
-+ // to NULL and delete the object.
++ // the list while the program is still
++ // running (LayoutMenu uses the index
++ // as a means of identifying layouts),
++ // the place in the layoutlist is set
++ // to NULL. The LayoutType object will
++ // be deleted.
++
+ layout = maLayoutList[index];
+ maLayoutList[index] = NULL;
+ if(layout) delete layout;
+ }
+ // take out of the menu lists. (Builtins are just removed from
-+ // menu lists).
++ // menu lists). Okay (in fact needed) in the menu's case to
++ // to use 'erase' and move up the elements.
+ removeFromMenuList((AutoLayout) index, PK_STANDARD);
+ removeFromMenuList((AutoLayout) index, PK_NOTES);
+ removeFromMenuList((AutoLayout) index, PK_HANDOUT);
+ }
+}
-+
++
++/** returns length of layout list. This
++ * may not be the number of actual layouts
++ * If some layouts are deleted, the list
++ * doesn't shrink in size. Use numberOfLayouts
++ * for a count of layouts and length to iterate
++ * through the layout list.
++ */
+
+sal_uInt32 LayoutList::length() const
+{
+ return maLayoutList.size();
+}
+
++/** number of actual layouts in the list. This is not
++ * the length (or number of elements) in the list
++ * itself. Use length() for iterating the list.
++ */
++
+sal_uInt32 LayoutList::numberOfLayouts() const
+{
+ sal_uInt32 count = 0;
@@ -1314,6 +1435,10 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return count;
+}
+
++/** Gets the layout object at the given index into the layout list.
++ * returns a NULL if the given index is out of range.
++ */
++
+LayoutType* LayoutList::getLayoutByIndex(const sal_uInt32 nIndex)
+{
+ // check for valid index (no need to check for less than zero)
@@ -1322,7 +1447,10 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return maLayoutList[nIndex];
+
+}
-+
++
++/** gets the layout object with the given name. Returns
++ * NULL if the name can't be found in the layout list.
++ */
+
+LayoutType* LayoutList::getLayoutByName(const LString& sName)
+{
@@ -1339,6 +1467,9 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+ return pLayout;
+}
++/** passes back the index into the layout list with a given name.
++ * Passes back LL_NOT_FOUND if the name is not in the list.
++ */
+
+sal_uInt32 LayoutList::getLayoutIndex(const LString& sName)
+{
@@ -1356,6 +1487,11 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return idx;
+}
+
++/** passes back the layout object associated with the (nIndex)th entry
++ * into the menu. Passes back a NULL if nIndex is out of range, not
++ * a valid menu type, or the layout doesn't exist.
++ */
++
+LayoutType* LayoutList::getLayoutAtMenuIndex(const sal_uInt32& nIndex,
+ const PageKind& eMenu)
+{
@@ -1380,6 +1516,9 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+}
+
++/** Gets the menu order index for a given layout list index. Passes
++ * back LL_NOT_FOUND if can't find layout or not a valid menu list */
++
+sal_uInt32 LayoutList::getMenuIndex(const AutoLayout& nLayout,
+ const PageKind& nMenu)
+{
@@ -1412,15 +1551,16 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return idx;
+ }
+
-+
-+
++/** passes back the length of the given menu order list.
++ * Passes back a zero if given an invalid menu type.
++ */
+
+sal_uInt32 LayoutList::getMenuLength(const PageKind& eMenu)
+{
+ sal_uInt32 size;
+
+ switch (eMenu) {
-+
++
+ case PK_STANDARD: size = maStandard.size();
+ break;
+ case PK_NOTES: size = maNotes.size();
@@ -1428,11 +1568,18 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ case PK_HANDOUT: size = maHandout.size();
+ break;
+ default: size = 0; // not a valid menu type
++
+ }
+
+ return size;
+}
+
++/** removes a given layout's index from the menu order list.
++ * Doesn't delete from the layout list. Uses 'erase' so
++ * the indices after the deleted layout are moved up one
++ * in the list.
++ */
++
+void LayoutList::removeFromMenuList(const AutoLayout& lnum,
+ const PageKind& eMenu)
+{
@@ -1452,6 +1599,13 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+
+}
++
++/** Adds a layout (or it's index in the layout list) to
++ * a given menu order list at the given index. If the
++ * given menu index is out of range (less than zero or
++ * larger than the list), the layout number is pushed on
++ * the end of the menu list.
++ */
+
+void LayoutList::addToMenuList(const sal_Int32& index,
+ const AutoLayout& lnum,
@@ -1490,6 +1644,24 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+}
+
++/** moves the place in the Layout menu for a particular layout
++* removes it's index in the list and then re-adds it according
++* to the passed-in menu index.
++*/
++
++void LayoutList::moveLayoutInMenu(const sal_Int32& nMenuIdx,
++ const AutoLayout& nIndex,
++ const PageKind& eMenu)
++{
++ removeFromMenuList(nIndex, eMenu);
++ addToMenuList(nMenuIdx, nIndex, eMenu);
++}
++
++/************** Start of UNO implementation of XLayoutList ****************************/
++
++/** helper functions used to convert from awt Rectangles to the tools
++ * rectangles (in gen.hxx)
++ */
+
+Rectangle LayoutList::UNORectToRect(const ::awt::Rectangle& rect)
+{
@@ -1514,9 +1686,10 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return awtrect;
+}
+
-+ /** UNO implementation of interface XLayoutList
-+ * for use with xmloff code
-+ */
++ /** passes back the bounding rectangles for a layout at a given
++ * index in the layout list.
++ * for use with xmloff code.
++ */
+Sequence< ::awt::Rectangle > SAL_CALL LayoutList::getAutoLayoutRectangles( sal_Int32 Index,
+ const ::awt::Rectangle& title,
+ const ::awt::Rectangle& layout,
@@ -1553,8 +1726,9 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return list;
+}
+
-+
-+
++/** gets the page kind of a given layout at an given index
++ * Used with xmloff code.
++ */
+
+::UnoPageKind SAL_CALL LayoutList::getPageKind(sal_Int32 Index)
+ throw (::uno::RuntimeException)
@@ -1571,6 +1745,11 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return kind;
+}
+
++/** gets the number of elements (presentation objects) for a given
++ * index of a layout.
++ * Used by the xmloff code.
++ */
++
+sal_Int32 SAL_CALL LayoutList::getElementCount(sal_Int32 Index)
+ throw (::uno::RuntimeException)
+{
@@ -1586,6 +1765,11 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return count;
+}
+
++/** passes back whether the element (with a given index) of the layout
++ * (of a given index) is vertical or not.
++ * Used by the xmloff code.
++ */
++
+sal_Bool SAL_CALL LayoutList::isVertical(sal_Int32 Index, sal_Int32 ElemIdx)
+ throw (::uno::RuntimeException)
+{
@@ -1601,6 +1785,10 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+ return bVertical;
+}
+
++/** passes back the presentation kind of a given element (with a given
++ * index) of a given layout (of a given index).
++ * Used by the xmloff code.
++ */
+
+::UnoPresKind SAL_CALL LayoutList::getPresKind(sal_Int32 Index, sal_Int32 ElemIdx)
+ throw (::uno::RuntimeException)
@@ -1618,10 +1806,18 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+}
+
+
++
++/** These functions are used to initialize the layout list
++ * with builtins if the configuration file doesn't exist.
++ * Probably will be removed at a later date when the
++ * installation has a configuration file to read in.
++ */
++
++/** puts the builtin layout indices in the menu
++ * order lists.
++ */
+void LayoutList::initializeMenuOrder()
+{
-+ // this probably would be best store in a file too.
-+ // for keeping track of menu order for builtins
+
+ maStandard.resize(25, LL_NOT_FOUND);
+ maNotes.resize(1, LL_NOT_FOUND);
@@ -1669,6 +1865,9 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
+}
+
++/** Initializes the layout list with the builtins.
++ */
++
+void LayoutList::initializeList()
+{
+ LayoutType* pLayout;
@@ -2254,8 +2453,8 @@ diff -Nrup sd-m16/source/core/layoutlist.cxx sd/source/core/layoutlist.cxx
+
diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
--- sd-m16/source/core/layouttype.cxx 1969-12-31 16:00:00.000000000 -0800
-+++ sd/source/core/layouttype.cxx 2009-07-31 00:10:16.000000000 -0700
-@@ -0,0 +1,859 @@
++++ sd/source/core/layouttype.cxx 2009-08-04 22:53:36.000000000 -0700
+@@ -0,0 +1,986 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -2330,6 +2529,9 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+static char sElemListTag[] = "ElementList";
+
+
++/** TODO: may need to change some of these defaults
++ * in the constructor.
++ */
+
+LayoutType::LayoutType() :
+ name(LString::CreateFromAscii("")),
@@ -2348,13 +2550,16 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+
+ for(sal_uInt32 i = 0; i < size; i++)
+ {
++ //need to delete element structures
+ deleteElement(i);
+ }
+
+ elemList.clear();
+}
+
-+/** writes the element list for this layout to the config file */
++/** helper function which writes the element list for this layout to
++ * the config file
++ */
+
+void LayoutType::writeElementTofile(FastSerializerHelper& fsh,
+ const sal_uInt32 i,
@@ -2372,7 +2577,7 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ static char sHt[10];
+ static char sWt[10];
+
-+
++ // set up strings to write to file
+ sprintf(sElemNumber,"%d", (int) i);
+ sprintf(sKind, "%d", (int) elem->kind); // the type of pres. object
+ sprintf(sVertical, "%d", ((elem->isVertical) ? 1 : 0));
@@ -2382,6 +2587,7 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ sprintf(sWt,"%f", elem->factorWt); // factor for finding width
+ sprintf(sRect, "%d", (int) elem->recttype); // type of standard rect to use
+
++ // put in a single element
+ fsh.singleElement(sLayoutTag,
+ sElemTag, sElemNumber,
+ sNumberTag, sNumber,
@@ -2396,7 +2602,8 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+
+}
+
-+/** writes this layout to a xml configuration file */
++/** Writes this layout to a xml configuration file
++ */
+
+void LayoutType::writeLayoutToFile(FastSerializerHelper& fsh, const sal_Int32 autolayout)
+{
@@ -2408,7 +2615,7 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ static char sLBitmap[10];
+ static char sPageKind[10];
+
-+ // write out layout information
++ // write out general layout information
+ sprintf(sNumber,"%d", (int) autolayout);
+ sprintf(sName,"%s", (char*) ByteString(name, RTL_TEXTENCODING_UTF8).GetBuffer());
+ sprintf(sStrId,"%d", (int) nStrId);
@@ -2417,8 +2624,11 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ sprintf(sLBitmap, "%d", (int) nLBitmapId);
+ sprintf(sPageKind, "%d", (int) nPageKind);
+
++ // <layout> (is this needed?)
+ fsh.startElement(sLayoutTag, NULL);
+
++ // write the general attributes in one
++ // single element <layout ...>
+ fsh.singleElement(sLayoutTag, sNameTag, sName,
+ sNumberTag, sNumber,
+ sStrIdTag, sStrId,
@@ -2431,20 +2641,27 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ // write out element list
+ ElemType* elem;
+
++ // <ElementList>
+ fsh.startElement(sElemListTag, NULL);
-+
++
+ for(sal_uInt32 i=0; i<length();i++)
+ {
+ elem = getElemByIndex(i);
+ if(elem) writeElementTofile(fsh, i, sNumber, elem);
+ }
-+
++
++ // </ElementList>
+ fsh.endElement(sElemListTag);
+
++ // </Layout>
+ fsh.endElement(sLayoutTag);
+
+}
+
++/** helper function to get an integer value from a
++ * xml node
++ */
++
+sal_Int32 LayoutType::getIntValue(const Reference<dom::XNode>& node)
+{
+ sal_Int32 num=0;
@@ -2458,6 +2675,9 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ return num;
+}
+
++/** helper function to get a double value from an xml node.
++ */
++
+double LayoutType::getDoubleValue(const Reference<dom::XNode>& node)
+{
+ double dnum=0.0;
@@ -2473,7 +2693,8 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+}
+
+/** reads in the layout information from
-+ * the configuration file
++ * the configuration file. This is called
++ * from the LayoutList class.
+ */
+
+sal_Int32 LayoutType::readLayoutFromFile(const Reference<dom::XNode>& node)
@@ -2488,48 +2709,57 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ {
+ Reference<dom::XNamedNodeMap> attrlist = layoutattrnode->getAttributes();
+
++ // get Resource ID for name
+ Reference<dom::XNode> anode = attrlist->getNamedItem(CHARTOOUSTR(sStrIdTag));
+ num = getIntValue(anode);
+ if(num > 0)
+ {
+ nStrId = num;
-+ } else
++ } else // this is a custom layout with no
++ // resource Id. set to -1
+ {
+ nStrId = -1;
+ }
++
++ // get name from file
+ Reference<dom::XNode> nameNode = attrlist->getNamedItem(CHARTOOUSTR(sNameTag));
+ rtl::OUString sName = nameNode->getNodeValue();
+ name = LString::CreateFromAscii(OUSTRTOCHAR(sName));
-+ //OSL_TRACE("AUTOLAYOUT NAME: %s", STRTOCHAR(name));
-+
++
++ // get writing mode
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sWmTag));
+ nWritingMode = (WritingMode) getIntValue(anode);
-+ //OSL_TRACE(" writing mode %d", (int) nWritingMode);
+
++ // get index into the layout list. This needs to
++ // be passed up to the layoutlist class for
++ // proper placement in the layout list.
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sNumberTag));
+ lnum = getIntValue(anode);
-+ //OSL_TRACE(" AutoLayout number %d", (int) lnum);
-+
++
++ // Get high (contrast?) bitmap Resource ID
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sHBitmapTag));
+ nHBitmapId = getIntValue(anode);
-+ //OSL_TRACE(" HBitmap ID: %d", (int) nHBitmapId);
-+
++
++ // Get low (contrast?) bitmap Resource ID
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sLBitmapTag));
+ nLBitmapId = getIntValue(anode);
-+ //OSL_TRACE(" LBitmap ID: %d", (int) nLBitmapId);
-+
++
++ // Get Page Kind (PK_STANDARD, PK_NOTES, PK_HANDOUT)
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sPageKindTag));
+ nPageKind = (PageKind) getIntValue(anode);
-+ //OSL_TRACE(" PageKind: %d", (int) nPageKind);
-+
++
+ }
+
++
++ // get the element list (or list of presentation objects) for
++ // this layout
++
+ Reference<dom::XNode> elemlistnode = topnodes->item(1);
+ Reference<dom::XNodeList> elemnodes = elemlistnode->getChildNodes();
+ sal_Int32 elemsize;
+
+ elemsize = elemnodes->getLength();
-+ //OSL_TRACE("NUMBER OF ELEM %d", elemsize);
++
+ for(sal_Int32 i=0; i < elemsize;i++)
+ {
+ Reference<dom::XNode> elemnode = elemnodes->item(i);
@@ -2538,42 +2768,44 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ {
+ Reference<dom::XNamedNodeMap> attrlist = elemnode->getAttributes();
+
++ // create a default element
+ createDefaultElement();
++
++ // get and set this element's presentation object kind
+ Reference<dom::XNode> anode = attrlist->getNamedItem(CHARTOOUSTR(sKindTag));
+ num = getIntValue(anode);
+ setPresKind(i, (PresObjKind) num);
-+ //OSL_TRACE(" Kind = %l", (long) getKind(i));
+
++ // get and set whether vertical or not
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sVerticalTag));
+ num = getIntValue(anode);
+ bool bVert = (num ? true : false);
+ setVertical(i, bVert);
-+ //OSL_TRACE(" isvertical = %d", (isVertical(i) ? 1 : 0));
+
++ // get and set the X factor
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sFxTag));
+ dnum = getDoubleValue(anode);
+ setFactorX(i, dnum);
-+ //OSL_TRACE(" X = %f", factorX(i));
-+
++
++ // get and set the Y factor
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sFyTag));
+ dnum = getDoubleValue(anode);
+ setFactorY(i, dnum);
-+ //OSL_TRACE(" Y = %f", factorY(i));
+
++ // get and set the Height factor
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sFhtTag));
+ dnum = getDoubleValue(anode);
+ setFactorHt(i, dnum);
-+ //OSL_TRACE(" Ht = %f", factorHt(i));
-+
++
++ // get and set the Weight factor
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sFwtTag));
+ dnum = getDoubleValue(anode);
+ setFactorWt(i, dnum);
-+ //OSL_TRACE(" Wt = %f", factorWt(i));
+
++ // get and set the type of rectangle to use (title, layout, etc.)
+ anode = attrlist->getNamedItem(CHARTOOUSTR(sRectTag));
+ num = getIntValue(anode);
+ setRecttype(i, (RectType) num);
-+ //OSL_TRACE(" recttype = %d", recttype(i));
+
+ }
+
@@ -2586,7 +2818,7 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+/** creates an element of type TITLE
+ * with default rect bounds.
+ * and puts it in the elem list
-+ * at the end.
++ * at the end.
+ */
+
+void LayoutType::createDefaultElement()
@@ -2605,33 +2837,56 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+
+}
+
-+/** Get functions for layout information */
++/** Get functions for layout information
++ */
+
++/** gets name of the layout to be put
++ * in the layout menu. Should use
++ * the string resource ID for builtin
++ * layouts.
++ */
+LString LayoutType::getName()
+{
+ return name;
+}
+
-+sal_uInt32 LayoutType::getStrId()
++/** Resource ID for the name to be
++ * put in the menu. This is set to
++ * -1 if there is no Resource ID
++ * such as when the layout is a
++ * custom layout.
++ */
++sal_Int32 LayoutType::getStrId()
+{
+ return nStrId;
+}
++/** get writing mode
++ */
+
+WritingMode LayoutType::getWritingMode()
+ {
+ return nWritingMode;
+ }
+
++/** get High (contrast?) bitmap resource ID
++ */
++
+sal_uInt32 LayoutType::getHBitmapId()
+{
+ return nHBitmapId;
+}
+
++/** get Low (contrast) bitmap resource ID
++ */
++
+sal_uInt32 LayoutType::getLBitmapId()
+{
+ return nLBitmapId;
+}
+
++/** get page kind (PK_STANDARD, PK_NOTES, PK_HANDOUT)
++ */
++
+PageKind LayoutType::getPageKind()
+{
+ return nPageKind;
@@ -2639,7 +2894,8 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+
+
+/** gets the element at the given index
-+ * into the elem list
++ * in the element list. Returns NULL
++ * if not found.
+ */
+
+ElemType* LayoutType::getElemByIndex(const sal_uInt32& nIndex)
@@ -2650,16 +2906,19 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ return elemList[nIndex];
+}
+
-+/** gets length of elem list. */
++/** gets length of elem list.
++ */
+
+sal_uInt32 LayoutType::length()
+{
+ return elemList.size();
+}
+
-+/** these are get functions for the element list
++/** these are get functions for the attributes of a
++ * particular element in the element list.
+ * They require passing in the index at which
-+ * the element is located in the list
++ * the element is located in the list.
++ * Passes back PRESOBJ_NONE if not found
+ */
+
+ PresObjKind LayoutType::getPresKind(const sal_uInt32& nIndex)
@@ -2671,7 +2930,10 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+
+ }
+
-+
++ /** gets whether an element is vertical or not.
++ * returns false if can't find element
++ */
++
+bool LayoutType::isVertical(const sal_uInt32& nIndex)
+{
+ ElemType* elem;
@@ -2680,6 +2942,10 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ return false;
+}
+
++/** gets the X factor for an element
++ * Passes back 0.0 if can't find element.
++ */
++
+double LayoutType::factorX(const sal_uInt32& nIndex)
+{
+ ElemType* elem;
@@ -2688,6 +2954,10 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ return 0.0;
+}
+
++/** gets the Y factor for an element
++ * returns 0.0 if can't find element
++ */
++
+double LayoutType::factorY(const sal_uInt32& nIndex)
+{
+ ElemType* elem;
@@ -2696,6 +2966,9 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ return 0.0;
+}
+
++/** gets the Height factor for an element
++ */
++
+double LayoutType::factorHt(const sal_uInt32& nIndex)
+{
+ ElemType* elem;
@@ -2704,6 +2977,10 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ return 1.0;
+}
+
++/** gets the Weight factor for an element
++ * Returns 1.0 if can't find element.
++ */
++
+double LayoutType::factorWt(const sal_uInt32& nIndex)
+{
+ ElemType* elem;
@@ -2712,41 +2989,68 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ return 1.0;
+}
+
++/** gets which type of rectange to use in
++ * determining bounding rectangle.
++ * Returns RT_MAX if it couldn't
++ * set the Rect type.
++ */
++
+RectType LayoutType::recttype(const sal_uInt32& nIndex)
+{
+ ElemType* elem;
+ elem = getElemByIndex(nIndex);
+ if(elem) return elem->recttype;
-+ return RT_ERROR;
++ return RT_MAX;
+}
+
-+/** Set functions for the layout */
-+
++/** Set functions for the attributes of the layout
++ */
++
++/** sets the name of the layout to be used in the
++ * layout list (if it is a custom layout). For
++ * localization, the builtins will use the string
++ * gotten through the Resource ID instead of the
++ * name.
++ */
+void LayoutType::setName(const LString& sName)
+{
+ name = sName;
+}
+
-+void LayoutType::setStrId(const sal_uInt32 id)
++/** sets the Resource ID of the string when
++ * the layout is a builtin. Otherwise, the
++ * layout is a custom and this is set to -1
++ */
++void LayoutType::setStrId(const sal_Int32 id)
+{
+ nStrId = id;
+}
+
++/** Sets the writing mode
++ */
++
+void LayoutType::setWritingMode(const WritingMode& wmode)
+{
+ nWritingMode = wmode;
+}
+
++/** Sets High (Contrast?) Bitmap Resource ID
++ */
++
+void LayoutType::setHBitmapId(const sal_uInt32& id)
+{
+ nHBitmapId = id;
+}
-+
++
++/** Sets Low (contrast?) Bitmap Resource ID
++ */
+void LayoutType::setLBitmapId(const sal_uInt32& id)
+{
+ nLBitmapId = id;
+}
+
++/** Sets Page Kind (PK_STANDARD, PK_NOTES, PK_HANDOUT)
++ */
+void LayoutType::setPageKind(const PageKind& kind)
+{
+ nPageKind = kind;
@@ -2758,13 +3062,16 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ * located
+ */
+
++/** sets the presenation object kind for an element
++ */
+void LayoutType::setPresKind(const sal_uInt32& nIndex, PresObjKind nKind)
+{
+ ElemType* elem;
+ elem = getElemByIndex(nIndex);
+ if(elem) elem->kind = nKind;
+}
-+
++/** sets whether the element is vertical or not
++ */
+
+void LayoutType::setVertical(const sal_uInt32& nIndex, bool bVertical)
+{
@@ -2773,6 +3080,9 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ if(elem) elem->isVertical = bVertical;
+}
+
++/** sets the X factor for an element
++ */
++
+void LayoutType::setFactorX(const sal_uInt32& nIndex, double fx)
+{
+ ElemType* elem;
@@ -2780,6 +3090,9 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ if(elem) elem->factorX = fx;
+}
+
++/** sets the Y factor for an element
++ */
++
+void LayoutType::setFactorY(const sal_uInt32& nIndex, double fy)
+{
+ ElemType* elem;
@@ -2787,6 +3100,9 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ if(elem) elem->factorY = fy;
+}
+
++/** Set the Height factor for an element
++ */
++
+void LayoutType::setFactorHt(const sal_uInt32& nIndex, double ht)
+{
+ ElemType* elem;
@@ -2794,12 +3110,18 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ if(elem) elem->factorHt = ht;
+}
+
++/** Sets the Width factor for an element
++ */
++
+void LayoutType::setFactorWt(const sal_uInt32& nIndex, double wt)
+{
+ ElemType* elem;
+ elem = getElemByIndex(nIndex);
+ if(elem) elem->factorWt = wt;
+}
++/** sets what rectangle to use in determining the
++ * bounding rectangle for the element
++ */
+
+void LayoutType::setRecttype(const sal_uInt32& nIndex, RectType rect)
+{
@@ -2832,84 +3154,7 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+ if(elem) delete elem;
+}
+
-+/** Helper function for initializing builtins
-+ * based on a given number. To possibly be
-+ * removed when the configuration files
-+ * are created
-+ */
+
-+void LayoutType::initFromLayoutNumber(ElemType* elem,
-+ const sal_uInt32& i,
-+ const sal_uInt32& nLayout)
-+{
-+ Point ncpos(0,0); //no changes to position
-+ Size ncsize(1,1); //no changes to size
-+ Size size;
-+ Point pos;
-+
-+ switch (nLayout)
-+
-+ {
-+ case 9: // title and 2 vertical side by side layouts
-+ case 1: // TITLE AND 2 side by side LAYOUTS
-+ // for right to left switching if needed.
-+ if(nLayout != 9) elem->recttype = RT_LAYOUT_SWITCH;
-+ elem->factorWt = .488;
-+ if(i == 2) elem->factorX = .5124;
-+ break;
-+ case 2: // TITLE on top, 1 right, 2 left layouts
-+ elem->recttype = RT_LAYOUT_SWITCH; // for right to left switching
-+ // if needed.
-+ elem->factorWt = .488;
-+ if((i == 2)||(i == 3)) //2 top to bot.
-+ {
-+ elem->factorHt = .477;
-+ elem->factorX = .5124;
-+ if(i == 3) elem->factorY = .5223;
-+ }
-+ break;
-+ case 3: //TITLE, 2 right, 1 left layouts
-+ elem->recttype = RT_LAYOUT_SWITCH; // for right to left switching
-+ // if needed.
-+ elem->factorWt = .488;
-+ if((i == 1)||(i == 2)) //2 top to bot.
-+ {
-+ elem->factorHt = .477;
-+ if(i == 2) elem->factorY = .5223;
-+ }
-+ if(i == 3) elem->factorX = .5124;
-+ break;
-+ case 4: //TITLE, 2 layouts top to bot.
-+ elem->factorHt = .477;
-+ if(i == 2) elem->factorY = .5223;
-+ break;
-+ case 5: //TITLE, 2 layouts above 1 layout
-+ elem->factorHt = .477;
-+ if(i != 3) elem->factorWt = .488;
-+ if(i == 2) elem->factorX = .5124;
-+ if(i == 3) elem->factorY = .5223;
-+ break;
-+ case 6: // 4 layouts (in a square)
-+ elem->factorHt = .477;
-+ elem->factorWt = .488;
-+ if((i == 2)||(i == 3)) elem->factorX = .5124;
-+ if((i == 3)||(i == 4)) elem->factorY = .5223;
-+ break;
-+ case 7: // a vertical title and two layouts (top to bottom)
-+ elem->recttype = RT_VERTICAL_LAYOUT;
-+ elem->factorHt = .47;
-+ elem->factorWt = .7;
-+ if(i == 2) elem->factorY = .53;
-+ break;
-+ case 8: // a vertical title and one shape
-+ elem->recttype = RT_VERTICAL_LAYOUT;
-+ elem->factorWt = .7;
-+ break;
-+ case 0:
-+ default: break; /* do nothing */
-+ } // switch nLayout
-+
-+}
+
+/** to be used when the user customizes
+ * an autolayout. It sets rect bounds
@@ -2953,79 +3198,9 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+
+}
+
-+/** for initializing rect bounds factors
-+ * for builtins. To be removed once the
-+ * configuration file is implemented.
-+ */
+
-+void LayoutType::initializeRectInfo(const sal_uInt32& nLayout)
-+{
-+ ElemType* elem;
-+ //Point ncpos(0,0); //no changes to position
-+ //Size ncsize(1,1); //no changes to size
-+ //Size size;
-+ //Point pos;
-+
-+ for(sal_uInt32 i=0; i < length();i++)
-+ {
-+ elem = getElemByIndex(i);
-+ if(!elem) continue;
-+ if(elem->kind == PRESOBJ_NONE) continue;
-+ // default to doing nothing with
-+ // the position and size.
-+ // this will work for 1/2 the
-+ // builtins (ones with 0 )
-+ // and works with some values
-+ // for the others.
-+ elem->factorX = 0.0;
-+ elem->factorY = 0.0;
-+ elem->factorHt = 1.0;
-+ elem->factorWt = 1.0;
-+ switch(elem->kind) {
-+ case PRESOBJ_TITLE:
-+ if(elem->isVertical)
-+ {
-+ elem->recttype = RT_VERTICAL_TITLE;
-+ }
-+ else
-+ {
-+ elem->recttype = RT_TITLE;
-+ }
-+ break;
-+ case PRESOBJ_TEXT:
-+ if(nLayout == 10) //TEXT_ONLY
-+ {
-+ elem->recttype = RT_TEXT_ONLY;
-+ break;
-+ }
-+ case PRESOBJ_OUTLINE:
-+ case PRESOBJ_GRAPHIC:
-+ case PRESOBJ_OBJECT:
-+ case PRESOBJ_CHART:
-+ case PRESOBJ_TABLE:
-+ elem->recttype = RT_LAYOUT;
-+ initFromLayoutNumber(elem,i, nLayout);
-+ break;
-+ case PRESOBJ_NONE:
-+ case PRESOBJ_ORGCHART:
-+ case PRESOBJ_IMAGE:
-+ case PRESOBJ_BACKGROUND:
-+ case PRESOBJ_PAGE:
-+ case PRESOBJ_HANDOUT:
-+ case PRESOBJ_NOTES:
-+ case PRESOBJ_HEADER:
-+ case PRESOBJ_FOOTER:
-+ case PRESOBJ_DATETIME:
-+ case PRESOBJ_SLIDENUMBER:
-+ case PRESOBJ_MAX:
-+ default: break; /* do nothing. all the above handled elsewhere */
-+ } //switch nKind
-+ } // for
-+
-+}
-+
-+/** the function called by sdpage.cxx to get rect bounds
-+ * from the factors for each element.
++/** the function called by sdpage.cxx to get rectangle boundaries
++ * from the factors for each element in one layout.
+ */
+
+void LayoutType::calcAutoLayoutRectangles(const Rectangle& aTitleRect,
@@ -3114,6 +3289,157 @@ diff -Nrup sd-m16/source/core/layouttype.cxx sd/source/core/layouttype.cxx
+
+}
+
++/** for initializing rect bounds factors
++ * for builtins. To be removed once the
++ * configuration file is implemented.
++ */
++
++void LayoutType::initializeRectInfo(const sal_uInt32& nLayout)
++{
++ ElemType* elem;
++ //Point ncpos(0,0); //no changes to position
++ //Size ncsize(1,1); //no changes to size
++ //Size size;
++ //Point pos;
++
++ for(sal_uInt32 i=0; i < length();i++)
++ {
++ elem = getElemByIndex(i);
++ if(!elem) continue;
++ if(elem->kind == PRESOBJ_NONE) continue;
++ // default to doing nothing with
++ // the position and size.
++ // this will work for 1/2 the
++ // builtins (ones with 0 )
++ // and works with some values
++ // for the others.
++ elem->factorX = 0.0;
++ elem->factorY = 0.0;
++ elem->factorHt = 1.0;
++ elem->factorWt = 1.0;
++ switch(elem->kind) {
++ case PRESOBJ_TITLE:
++ if(elem->isVertical)
++ {
++ elem->recttype = RT_VERTICAL_TITLE;
++ }
++ else
++ {
++ elem->recttype = RT_TITLE;
++ }
++ break;
++ case PRESOBJ_TEXT:
++ if(nLayout == 10) //TEXT_ONLY
++ {
++ elem->recttype = RT_TEXT_ONLY;
++ break;
++ }
++ case PRESOBJ_OUTLINE:
++ case PRESOBJ_GRAPHIC:
++ case PRESOBJ_OBJECT:
++ case PRESOBJ_CHART:
++ case PRESOBJ_TABLE:
++ elem->recttype = RT_LAYOUT;
++ initFromLayoutNumber(elem,i, nLayout);
++ break;
++ case PRESOBJ_NONE:
++ case PRESOBJ_ORGCHART:
++ case PRESOBJ_IMAGE:
++ case PRESOBJ_BACKGROUND:
++ case PRESOBJ_PAGE:
++ case PRESOBJ_HANDOUT:
++ case PRESOBJ_NOTES:
++ case PRESOBJ_HEADER:
++ case PRESOBJ_FOOTER:
++ case PRESOBJ_DATETIME:
++ case PRESOBJ_SLIDENUMBER:
++ case PRESOBJ_MAX:
++ default: break; /* do nothing. all the above handled elsewhere */
++ } //switch nKind
++ } // for
++
++}
++
++/** Helper function for initializing builtins
++ * based on a given number. To possibly be
++ * removed when the configuration files
++ * are created
++ */
++
++void LayoutType::initFromLayoutNumber(ElemType* elem,
++ const sal_uInt32& i,
++ const sal_uInt32& nLayout)
++{
++ Point ncpos(0,0); //no changes to position
++ Size ncsize(1,1); //no changes to size
++ Size size;
++ Point pos;
++
++ switch (nLayout)
++
++ {
++ case 9: // title and 2 vertical side by side layouts
++ case 1: // TITLE AND 2 side by side LAYOUTS
++ // for right to left switching if needed.
++ if(nLayout != 9) elem->recttype = RT_LAYOUT_SWITCH;
++ elem->factorWt = .488;
++ if(i == 2) elem->factorX = .5124;
++ break;
++ case 2: // TITLE on top, 1 right, 2 left layouts
++ elem->recttype = RT_LAYOUT_SWITCH; // for right to left switching
++ // if needed.
++ elem->factorWt = .488;
++ if((i == 2)||(i == 3)) //2 top to bot.
++ {
++ elem->factorHt = .477;
++ elem->factorX = .5124;
++ if(i == 3) elem->factorY = .5223;
++ }
++ break;
++ case 3: //TITLE, 2 right, 1 left layouts
++ elem->recttype = RT_LAYOUT_SWITCH; // for right to left switching
++ // if needed.
++ elem->factorWt = .488;
++ if((i == 1)||(i == 2)) //2 top to bot.
++ {
++ elem->factorHt = .477;
++ if(i == 2) elem->factorY = .5223;
++ }
++ if(i == 3) elem->factorX = .5124;
++ break;
++ case 4: //TITLE, 2 layouts top to bot.
++ elem->factorHt = .477;
++ if(i == 2) elem->factorY = .5223;
++ break;
++ case 5: //TITLE, 2 layouts above 1 layout
++ elem->factorHt = .477;
++ if(i != 3) elem->factorWt = .488;
++ if(i == 2) elem->factorX = .5124;
++ if(i == 3) elem->factorY = .5223;
++ break;
++ case 6: // 4 layouts (in a square)
++ elem->factorHt = .477;
++ elem->factorWt = .488;
++ if((i == 2)||(i == 3)) elem->factorX = .5124;
++ if((i == 3)||(i == 4)) elem->factorY = .5223;
++ break;
++ case 7: // a vertical title and two layouts (top to bottom)
++ elem->recttype = RT_VERTICAL_LAYOUT;
++ elem->factorHt = .47;
++ elem->factorWt = .7;
++ if(i == 2) elem->factorY = .53;
++ break;
++ case 8: // a vertical title and one shape
++ elem->recttype = RT_VERTICAL_LAYOUT;
++ elem->factorWt = .7;
++ break;
++ case 0:
++ default: break; /* do nothing */
++ } // switch nLayout
++
++}
++
++
+
diff -Nrup sd-m16/source/core/makefile.mk sd/source/core/makefile.mk
--- sd-m16/source/core/makefile.mk 2009-07-25 19:25:13.000000000 -0700
@@ -3788,7 +4114,7 @@ diff -Nrup sd-m16/source/ui/slidesorter/controller/SlsSlotManager.cxx sd/source/
break;
diff -Nrup sd-m16/source/ui/toolpanel/LayoutMenu.cxx sd/source/ui/toolpanel/LayoutMenu.cxx
--- sd-m16/source/ui/toolpanel/LayoutMenu.cxx 2009-07-25 19:25:16.000000000 -0700
-+++ sd/source/ui/toolpanel/LayoutMenu.cxx 2009-07-31 00:10:16.000000000 -0700
++++ sd/source/ui/toolpanel/LayoutMenu.cxx 2009-08-04 23:40:41.000000000 -0700
@@ -129,99 +129,6 @@ SFX_IMPL_INTERFACE(LayoutMenu, SfxShell,
TYPEINIT1(LayoutMenu, SfxShell);
@@ -4000,9 +4326,920 @@ diff -Nrup sd-m16/source/ui/toolpanel/LayoutMenu.cxx sd/source/ui/toolpanel/Layo
// Find the entry of the menu for to the layout.
USHORT nItemCount (GetItemCount());
for (USHORT nId=1; nId<=nItemCount; nId++)
+diff -Nrup sd-m16/source/ui/toolpanel/LayoutMenu.cxx.orig sd/source/ui/toolpanel/LayoutMenu.cxx.orig
+--- sd-m16/source/ui/toolpanel/LayoutMenu.cxx.orig 1969-12-31 16:00:00.000000000 -0800
++++ sd/source/ui/toolpanel/LayoutMenu.cxx.orig 2009-08-04 23:23:46.000000000 -0700
+@@ -0,0 +1,907 @@
++/*************************************************************************
++ *
++ * 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: LayoutMenu.cxx,v $
++ * $Revision: 1.27 $
++ *
++ * 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 "LayoutMenu.hxx"
++
++#include "TaskPaneShellManager.hxx"
++#include "pres.hxx"
++#include "drawdoc.hxx"
++#include "DrawDocShell.hxx"
++#include "sdpage.hxx"
++#include "glob.hxx"
++#include "glob.hrc"
++#include "app.hrc"
++#include "helpids.h"
++#include "res_bmp.hrc"
++#include "strings.hrc"
++#include "ViewShellBase.hxx"
++#include "DrawViewShell.hxx"
++#include "SlideSorterViewShell.hxx"
++#include "controller/SlideSorterController.hxx"
++#include "controller/SlsPageSelector.hxx"
++#include "taskpane/TaskPaneControlFactory.hxx"
++#include "taskpane/ScrollPanel.hxx"
++#include "tools/SlotStateListener.hxx"
++#include "EventMultiplexer.hxx"
++#include "DrawController.hxx"
++#include "framework/FrameworkHelper.hxx"
++
++#include <vector>
++#include <memory>
++#include <sfx2/objface.hxx>
++#include "sdresid.hxx"
++#include <vcl/image.hxx>
++#include <svtools/languageoptions.hxx>
++#include <sfx2/app.hxx>
++#include <sfx2/dispatch.hxx>
++#include <sfx2/request.hxx>
++#include <comphelper/processfactory.hxx>
++#include <sfx2/viewfrm.hxx>
++
++#include <com/sun/star/frame/XController.hpp>
++#include <com/sun/star/drawing/framework/XControllerManager.hpp>
++#include <com/sun/star/drawing/framework/XView.hpp>
++#include <com/sun/star/drawing/framework/ResourceId.hpp>
++
++using namespace ::sd::toolpanel;
++#define LayoutMenu
++#include "sdslots.hxx"
++
++using namespace ::com::sun::star;
++using namespace ::com::sun::star::text;
++using namespace ::com::sun::star::uno;
++using namespace ::com::sun::star::drawing::framework;
++using namespace ::sd::slidesorter;
++using ::sd::framework::FrameworkHelper;
++
++namespace sd { namespace toolpanel {
++
++/** This factory class stores references to ViewShellBase and DrawDocShell
++ and passes them to new LayoutMenu objects.
++*/
++class LayoutMenuFactory
++ : public ControlFactory
++{
++public:
++ LayoutMenuFactory (ViewShellBase& rBase, DrawDocShell& rDocShell)
++ : mrBase(rBase),
++ mrDocShell(rDocShell)
++ {}
++
++protected:
++ virtual TreeNode* InternalCreateControl (TreeNode* pTreeNode)
++ {
++ ScrollPanel* pScrollPanel = new ScrollPanel (pTreeNode);
++ ::std::auto_ptr<TreeNode> pMenu (
++ new LayoutMenu (
++ pScrollPanel,
++ mrDocShell,
++ mrBase,
++ false));
++ pScrollPanel->AddControl(pMenu);
++ return pScrollPanel;
++ }
++
++private:
++ ViewShellBase& mrBase;
++ DrawDocShell& mrDocShell;
++};
++
++
++
++
++SFX_IMPL_INTERFACE(LayoutMenu, SfxShell,
++ SdResId(STR_TASKPANELAYOUTMENU))
++{
++ SFX_POPUPMENU_REGISTRATION(SdResId(RID_TASKPANE_LAYOUTMENU_POPUP));
++}
++
++TYPEINIT1(LayoutMenu, SfxShell);
++
++LayoutMenu::LayoutMenu (
++ TreeNode* pParent,
++ DrawDocShell& rDocumentShell,
++ ViewShellBase& rViewShellBase,
++ bool bUseOwnScrollBar)
++ : ValueSet (pParent->GetWindow()),
++ TreeNode(pParent),
++ DragSourceHelper(this),
++ DropTargetHelper(this),
++ mrBase (rViewShellBase),
++ mbUseOwnScrollBar (bUseOwnScrollBar),
++ mnPreferredColumnCount(3),
++ mxListener(NULL),
++ mbSelectionUpdatePending(true),
++ mbIsMainViewChangePending(false)
++{
++ SetStyle (
++ GetStyle()
++ & ~(WB_ITEMBORDER)
++ | WB_TABSTOP
++ | WB_NO_DIRECTSELECT
++ );
++ if (mbUseOwnScrollBar)
++ SetStyle (GetStyle() | WB_VSCROLL);
++ SetExtraSpacing(2);
++ SetSelectHdl (LINK(this, LayoutMenu, ClickHandler));
++ SetPool (&rDocumentShell.GetDoc()->GetPool());
++ SetName(String(RTL_CONSTASCII_USTRINGPARAM("LayoutMenu")));
++ InvalidateContent();
++
++ Link aEventListenerLink (LINK(this,LayoutMenu,EventMultiplexerListener));
++ mrBase.GetEventMultiplexer()->AddEventListener(aEventListenerLink,
++ ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE
++ | ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION
++ | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED
++ | ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED
++ | ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED);
++
++ SetSmartHelpId(SmartId(HID_SD_TASK_PANE_PREVIEW_LAYOUTS));
++ SetAccessibleName(SdResId(STR_TASKPANEL_LAYOUT_MENU_TITLE));
++
++ Link aStateChangeLink (LINK(this,LayoutMenu,StateChangeHandler));
++ mxListener = new ::sd::tools::SlotStateListener(
++ aStateChangeLink,
++ Reference<frame::XDispatchProvider>(mrBase.GetController()->getFrame(), UNO_QUERY),
++ ::rtl::OUString::createFromAscii(".uno:VerticalTextState"));
++
++ // Add this new object as shell to the shell factory.
++ GetShellManager()->AddSubShell(HID_SD_TASK_PANE_PREVIEW_LAYOUTS,this,this);
++}
++
++
++
++
++LayoutMenu::~LayoutMenu (void)
++{
++ // Tell the shell factory that this object is no longer available.
++ if (GetShellManager() != NULL)
++ GetShellManager()->RemoveSubShell(this);
++
++ Reference<lang::XComponent> xComponent (mxListener, UNO_QUERY);
++ if (xComponent.is())
++ xComponent->dispose();
++
++ Clear();
++ Link aLink (LINK(this,LayoutMenu,EventMultiplexerListener));
++ mrBase.GetEventMultiplexer()->RemoveEventListener (aLink);
++}
++
++
++
++
++::std::auto_ptr<ControlFactory> LayoutMenu::CreateControlFactory (
++ ViewShellBase& rBase,
++ DrawDocShell& rDocShell)
++{
++ return ::std::auto_ptr<ControlFactory>(new LayoutMenuFactory(rBase, rDocShell));
++}
++
++
++
++
++String LayoutMenu::GetSelectedLayoutName (void)
++{
++ return GetItemText (GetSelectItemId());
++}
++
++
++
++
++AutoLayout LayoutMenu::GetSelectedAutoLayout (void)
++{
++ AutoLayout aResult = AUTOLAYOUT_NONE;
++
++ if ( ! IsNoSelection() && GetSelectItemId()!=0)
++ {
++ AutoLayout* pLayout = static_cast<AutoLayout*>(GetItemData(GetSelectItemId()));
++ if (pLayout != NULL)
++ aResult = *pLayout;
++ }
++
++ return aResult;
++}
++
++
++
++
++/** The preferred size depends on the preferred number of columns, the
++ number of items, and the size of the items.
++*/
++Size LayoutMenu::GetPreferredSize (void)
++{
++ Size aItemSize = CalcItemSizePixel (Size());
++ Size aPreferredWindowSize = CalcWindowSizePixel (
++ aItemSize,
++ (USHORT)mnPreferredColumnCount,
++ (USHORT)CalculateRowCount (aItemSize,mnPreferredColumnCount));
++ return aPreferredWindowSize;
++}
++
++
++
++
++sal_Int32 LayoutMenu::GetPreferredWidth (sal_Int32 nHeight)
++{
++ sal_Int32 nPreferredWidth = 100;
++ if (GetItemCount() > 0)
++ {
++ Image aImage = GetItemImage(GetItemId(0));
++ Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel());
++ if (nHeight>0 && aItemSize.Height()>0)
++ {
++ int nRowCount = nHeight / aItemSize.Height();
++ if (nRowCount <= 0)
++ nRowCount = 1;
++ int nColumnCount = (GetItemCount() + nRowCount-1) / nRowCount;
++ nPreferredWidth = nColumnCount * aItemSize.Width();
++ }
++ }
++
++ return nPreferredWidth;
++}
++
++
++
++
++sal_Int32 LayoutMenu::GetPreferredHeight (sal_Int32 nWidth)
++{
++ sal_Int32 nPreferredHeight = 200;
++ if ( ! mbUseOwnScrollBar && GetItemCount()>0)
++ {
++ Image aImage = GetItemImage(GetItemId(0));
++ Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel());
++ if (nWidth>0 && aItemSize.Width()>0)
++ {
++ aItemSize.Width() += 8;
++ aItemSize.Height() += 8;
++ int nColumnCount = nWidth / aItemSize.Width();
++ if (nColumnCount <= 0)
++ nColumnCount = 1;
++ else if (nColumnCount > 4)
++ nColumnCount = 4;
++ int nRowCount = (GetItemCount() + nColumnCount-1) / nColumnCount;
++ nPreferredHeight = nRowCount * aItemSize.Height();
++ }
++ }
++ return nPreferredHeight;
++}
++
++
++
++
++sal_Int32 LayoutMenu::GetMinimumWidth (void)
++{
++ sal_Int32 nMinimumWidth = 0;
++ if (GetItemCount()>0)
++ {
++ Image aImage = GetItemImage(GetItemId(0));
++ Size aItemSize = CalcItemSizePixel (aImage.GetSizePixel());
++ nMinimumWidth = aItemSize.Width();
++ }
++ return nMinimumWidth;
++}
++
++
++
++
++bool LayoutMenu::IsResizable (void)
++{
++ return true;
++}
++
++
++
++
++::Window* LayoutMenu::GetWindow (void)
++{
++ return this;
++}
++
++
++
++
++void LayoutMenu::Paint (const Rectangle& rRect)
++{
++ SetBackground (GetSettings().GetStyleSettings().GetWindowColor());
++
++ if (mbSelectionUpdatePending)
++ {
++ mbSelectionUpdatePending = false;
++ UpdateSelection();
++ }
++ ValueSet::Paint (rRect);
++
++ SetBackground (Wallpaper());
++}
++
++
++
++
++void LayoutMenu::Resize (void)
++{
++ Size aWindowSize = GetOutputSizePixel();
++ if (IsVisible() && aWindowSize.Width() > 0)
++ {
++ // Calculate the number of rows and columns.
++ if (GetItemCount() > 0)
++ {
++ Image aImage = GetItemImage(GetItemId(0));
++ Size aItemSize = CalcItemSizePixel (
++ aImage.GetSizePixel());
++ aItemSize.Width() += 8;
++ aItemSize.Height() += 8;
++ int nColumnCount = aWindowSize.Width() / aItemSize.Width();
++ if (nColumnCount < 1)
++ nColumnCount = 1;
++ else if (nColumnCount > 4)
++ nColumnCount = 4;
++
++ int nRowCount = CalculateRowCount (aItemSize, nColumnCount);
++
++ SetColCount ((USHORT)nColumnCount);
++ SetLineCount ((USHORT)nRowCount);
++ }
++ }
++
++ ValueSet::Resize ();
++}
++
++
++
++
++void LayoutMenu::MouseButtonDown (const MouseEvent& rEvent)
++{
++ // As a preparation for the context menu the item under the mouse is
++ // selected.
++ if (rEvent.IsRight())
++ {
++ ReleaseMouse();
++ USHORT nIndex = GetItemId (rEvent.GetPosPixel());
++ if (nIndex > 0)
++ SelectItem(nIndex);
++ }
++
++ ValueSet::MouseButtonDown (rEvent);
++}
++
++
++
++
++void LayoutMenu::Execute (SfxRequest& rRequest)
++{
++ switch (rRequest.GetSlot())
++ {
++ case SID_TP_APPLY_TO_SELECTED_SLIDES:
++ AssignLayoutToSelectedSlides(GetSelectedAutoLayout());
++ rRequest.Done();
++ break;
++
++ case SID_INSERTPAGE_LAYOUT_MENU:
++ // Add arguments to this slot and forward it to the main view
++ // shell.
++ InsertPageWithLayout(GetSelectedAutoLayout());
++ break;
++ }
++}
++
++
++
++
++void LayoutMenu::GetState (SfxItemSet& rItemSet)
++{
++ // Cut and paste is not supported. The SID_(CUT,COPY,PASTE) entries
++ // therefore must not show up in the context menu.
++ rItemSet.DisableItem (SID_CUT);
++ rItemSet.DisableItem (SID_COPY);
++ rItemSet.DisableItem (SID_PASTE);
++
++ // The SID_INSERTPAGE_LAYOUT_MENU slot depends on the SID_INSERTPAGE
++ // slot being supported elsewhere.
++ const SfxPoolItem* pItem = NULL;
++ const SfxItemState aState (
++ mrBase.GetViewFrame()->GetDispatcher()->QueryState(SID_INSERTPAGE, pItem));
++ if (aState == SFX_ITEM_DISABLED)
++ rItemSet.DisableItem(SID_INSERTPAGE_LAYOUT_MENU);
++}
++
++
++
++
++void LayoutMenu::InsertPageWithLayout (AutoLayout aLayout)
++{
++ ViewShell* pViewShell = mrBase.GetMainViewShell().get();
++ if (pViewShell == NULL)
++ return;
++
++ SfxViewFrame* pViewFrame = mrBase.GetViewFrame();
++ if (pViewFrame == NULL)
++ return;
++
++ SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
++ if (pDispatcher == NULL)
++ return;
++
++ // Call SID_INSERTPAGE with the right arguments. This is because
++ // the popup menu can not call this slot with arguments directly.
++ SfxRequest aRequest (CreateRequest(SID_INSERTPAGE, aLayout));
++ if (aRequest.GetArgs() != NULL)
++ {
++ pDispatcher->Execute(
++ SID_INSERTPAGE,
++ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
++ *aRequest.GetArgs());
++ }
++ UpdateSelection();
++}
++
++
++
++
++void LayoutMenu::InvalidateContent (void)
++{
++ // The number of items may have changed. Request a resize so that the
++ // vertical size of this control can be adapted.
++ RequestResize();
++
++ // Throw away the current set and fill the menu anew according to the
++ // current settings (this includes the support for vertical writing.)
++ Fill();
++}
++
++
++
++
++int LayoutMenu::CalculateRowCount (const Size&, int nColumnCount)
++{
++ int nRowCount = 0;
++
++ if (GetItemCount() > 0 && nColumnCount > 0)
++ {
++ nRowCount = (GetItemCount() + nColumnCount - 1) / nColumnCount;
++ // nRowCount = GetOutputSizePixel().Height() / rItemSize.Height();
++ if (nRowCount < 1)
++ nRowCount = 1;
++ }
++
++ return nRowCount;
++}
++
++
++
++
++IMPL_LINK(LayoutMenu, ClickHandler, ValueSet*, EMPTYARG)
++{
++ AssignLayoutToSelectedSlides (GetSelectedAutoLayout());
++ return 0;
++}
++
++
++
++
++/** The specified layout is assigned to the current page of the view shell
++ in the center pane.
++*/
++void LayoutMenu::AssignLayoutToSelectedSlides (AutoLayout aLayout)
++{
++ using namespace ::sd::slidesorter;
++ using namespace ::sd::slidesorter::controller;
++
++ do
++ {
++ // The view shell in the center pane has to be present.
++ ViewShell* pMainViewShell = mrBase.GetMainViewShell().get();
++ if (pMainViewShell == NULL)
++ break;
++
++ // Determine if the current view is in an invalid master page mode.
++ // The handout view is always in master page mode and therefore not
++ // invalid.
++ bool bMasterPageMode (false);
++ switch (pMainViewShell->GetShellType())
++ {
++ case ViewShell::ST_NOTES:
++ case ViewShell::ST_IMPRESS:
++ {
++ DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(pMainViewShell);
++ if (pDrawViewShell != NULL)
++ if (pDrawViewShell->GetEditMode() == EM_MASTERPAGE)
++ bMasterPageMode = true;
++ }
++ default:
++ break;
++ }
++ if (bMasterPageMode)
++ break;
++
++ // Get a list of all selected slides and call the SID_MODIFYPAGE
++ // slot for all of them.
++ ::sd::slidesorter::SharedPageSelection pPageSelection;
++
++ // Get a list of selected pages.
++ // First we try to obtain this list from a slide sorter. This is
++ // possible only some of the view shells in the center pane. When
++ // no valid slide sorter is available then ask the main view shell
++ // for its current page.
++ SlideSorterViewShell* pSlideSorter = NULL;
++ switch (pMainViewShell->GetShellType())
++ {
++ case ViewShell::ST_IMPRESS:
++ case ViewShell::ST_NOTES:
++ case ViewShell::ST_SLIDE_SORTER:
++ pSlideSorter = SlideSorterViewShell::GetSlideSorter(mrBase);
++ break;
++ default:
++ break;
++ }
++ if (pSlideSorter != NULL)
++ {
++ // There is a slide sorter visible so get the list of selected pages from it.
++ pPageSelection = pSlideSorter->GetPageSelection();
++ }
++ else
++ {
++ // No valid slide sorter available. Ask the main view shell for
++ // its current page.
++ pPageSelection.reset(new ::sd::slidesorter::SlideSorterViewShell::PageSelection());
++ pPageSelection->push_back(pMainViewShell->GetActualPage());
++ }
++
++
++ if (pPageSelection->empty())
++ break;
++
++ ::std::vector<SdPage*>::iterator iPage;
++ for (iPage=pPageSelection->begin(); iPage!=pPageSelection->end(); ++iPage)
++ {
++ if ((*iPage) == NULL)
++ continue;
++
++ // Call the SID_ASSIGN_LAYOUT slot with all the necessary parameters.
++ SfxRequest aRequest (mrBase.GetViewFrame(), SID_ASSIGN_LAYOUT);
++ aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATPAGE, ((*iPage)->GetPageNum()-1)/2));
++ aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout));
++ pMainViewShell->ExecuteSlot (aRequest, BOOL(FALSE));
++ }
++ }
++ while(false);
++}
++
++
++
++
++SfxRequest LayoutMenu::CreateRequest (
++ USHORT nSlotId,
++ AutoLayout aLayout)
++{
++ SfxRequest aRequest (mrBase.GetViewFrame(), nSlotId);
++
++ do
++ {
++ SdrLayerAdmin& rLayerAdmin (mrBase.GetDocument()->GetLayerAdmin());
++ BYTE aBackground (rLayerAdmin.GetLayerID(
++ String(SdResId(STR_LAYER_BCKGRND)), FALSE));
++ BYTE aBackgroundObject (rLayerAdmin.GetLayerID(
++ String(SdResId(STR_LAYER_BCKGRNDOBJ)), FALSE));
++ ViewShell* pViewShell = mrBase.GetMainViewShell().get();
++ if (pViewShell == NULL)
++ break;
++ SdPage* pPage = pViewShell->GetActualPage();
++ if (pPage == NULL)
++ break;
++
++ SetOfByte aVisibleLayers (pPage->TRG_GetMasterPageVisibleLayers());
++
++ aRequest.AppendItem(
++ SfxStringItem (ID_VAL_PAGENAME, String()));//pPage->GetName()));
++ aRequest.AppendItem(SfxUInt32Item (ID_VAL_WHATLAYOUT, aLayout));
++ aRequest.AppendItem(
++ SfxBoolItem(ID_VAL_ISPAGEBACK, aVisibleLayers.IsSet(aBackground)));
++ aRequest.AppendItem(
++ SfxBoolItem(
++ ID_VAL_ISPAGEOBJ,
++ aVisibleLayers.IsSet(aBackgroundObject)));
++ }
++ while (false);
++
++ return aRequest;
++}
++
++
++
++
++void LayoutMenu::Fill (void)
++{
++ const bool bHighContrast = GetDisplayBackground().GetColor().IsDark() != 0;
++ SvtLanguageOptions aLanguageOptions;
++ sal_Bool bVertical = aLanguageOptions.IsVerticalTextEnabled();
++ SdDrawDocument* pDocument = mrBase.GetDocument();
++ sal_Bool bRightToLeft = (pDocument!=NULL
++ && pDocument->GetDefaultWritingMode() == WritingMode_RL_TB);
++
++ // Get URL of the view in the center pane.
++ ::rtl::OUString sCenterPaneViewName;
++ try
++ {
++ Reference<XControllerManager> xControllerManager (
++ Reference<XWeak>(&mrBase.GetDrawController()), UNO_QUERY_THROW);
++ Reference<XResourceId> xPaneId (ResourceId::create(
++ comphelper_getProcessComponentContext(),
++ FrameworkHelper::msCenterPaneURL));
++ Reference<XView> xView (FrameworkHelper::Instance(mrBase)->GetView(xPaneId));
++ if (xView.is())
++ sCenterPaneViewName = xView->getResourceId()->getResourceURL();
++ }
++ catch (RuntimeException&)
++ {}
++
++ LayoutList* list = GetLayoutList();
++ PageKind eMenu;
++ bool aViewExists = true;
++ LayoutType* layout;
++
++ if (sCenterPaneViewName.equals(framework::FrameworkHelper::msNotesViewURL))
++ {
++ eMenu = PK_NOTES;
++ }
++ else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msHandoutViewURL))
++ {
++ eMenu = PK_HANDOUT;
++ }
++ else if (sCenterPaneViewName.equals(framework::FrameworkHelper::msImpressViewURL)
++ || sCenterPaneViewName.equals(framework::FrameworkHelper::msSlideSorterURL))
++ {
++ eMenu = PK_STANDARD;
++ }
++ else
++ {
++ eMenu = PK_STANDARD;
++ aViewExists = false;
++ }
++
++ Clear();
++
++ WritingMode wm;
++ AutoLayout lnum;
++ sal_uInt32 index;
++ sal_Int32 resId;
++ sal_uInt32 Hbitmap, Lbitmap;
++ LString name;
++
++ sal_uInt32 size = list->getMenuLength(eMenu);
++
++ index = 1;
++ if (aViewExists) {
++ for (sal_uInt16 i=0; i < size; i++)
++ {
++ layout = list->getLayoutAtMenuIndex(i,eMenu);
++ if(layout)
++ {
++ name = layout->getName();
++ lnum = list->getLayoutIndex(name);
++ if(lnum == LL_NOT_FOUND)
++ {
++ continue;
++ }
++ resId = layout->getStrId();
++ if(resId != -1) // if it has an ID, pull string from resource.
++ {
++ name = SdResId(resId);
++ }
++ wm = layout->getWritingMode();
++ Hbitmap = layout->getHBitmapId();
++ Lbitmap = layout->getLBitmapId();
++ if((wm != WritingMode_TB_RL) || bVertical)
++ {
++ BitmapEx aBmp (SdResId (bHighContrast
++ ? Hbitmap
++ : Lbitmap));
++ if(bRightToLeft && (wm != WritingMode_TB_RL))
++ aBmp.Mirror(BMP_MIRROR_HORZ);
++ InsertItem (index, aBmp, name);
++ SetItemData (index, new AutoLayout(lnum));
++ index++;
++
++ } //if wm...
++ } //if layout..
++ } // for...
++ } // if (aViewExists...
++
++ mbSelectionUpdatePending = true;
++}
++
++
++
++
++void LayoutMenu::Clear (void)
++{
++ for (USHORT nId=1; nId<=GetItemCount(); nId++)
++ delete static_cast<AutoLayout*>(GetItemData(nId));
++ ValueSet::Clear();
++}
++
++
++
++void LayoutMenu::StartDrag (sal_Int8 , const Point& )
++{
++}
++
++
++
++
++sal_Int8 LayoutMenu::AcceptDrop (const AcceptDropEvent& )
++{
++ return 0;
++}
++
++
++
++
++sal_Int8 LayoutMenu::ExecuteDrop (const ExecuteDropEvent& )
++{
++ return 0;
++}
++
++
++
++
++void LayoutMenu::Command (const CommandEvent& rEvent)
++{
++ switch (rEvent.GetCommand())
++ {
++ case COMMAND_CONTEXTMENU:
++ if ( ! SD_MOD()->GetWaterCan())
++ {
++ if (GetShellManager() != NULL)
++ GetShellManager()->MoveToTop(this);
++ if (rEvent.IsMouseEvent())
++ mrBase.GetViewFrame()->GetDispatcher()->ExecutePopup(
++ SdResId(RID_TASKPANE_LAYOUTMENU_POPUP));
++ else
++ {
++ // When the command event was not caused by a mouse
++ // event (for example a key press instead) then show the
++ // popup menu at the center of the current item.
++ if (GetSelectItemId() != (USHORT)-1)
++ {
++ Rectangle aBBox (GetItemRect(GetSelectItemId()));
++ Point aPosition (aBBox.Center());
++ mrBase.GetViewFrame()->GetDispatcher()->ExecutePopup(
++ SdResId(RID_TASKPANE_LAYOUTMENU_POPUP),
++ this,
++ &aPosition);
++ }
++ }
++ }
++ break;
++
++ default:
++ ValueSet::Command(rEvent);
++ break;
++ }
++}
++
++
++
++
++IMPL_LINK(LayoutMenu, StateChangeHandler, ::rtl::OUString*, EMPTYARG)
++{
++ InvalidateContent();
++ return 0;
++}
++
++
++
++
++void LayoutMenu::UpdateSelection (void)
++{
++ bool bItemSelected = false;
++
++ do
++ {
++ // Get current page of main view.
++ ViewShell* pViewShell = mrBase.GetMainViewShell().get();
++ if (pViewShell == NULL)
++ break;
++
++ SdPage* pCurrentPage = pViewShell->getCurrentPage();
++ if (pCurrentPage == NULL)
++ break;
++
++ // Get layout of current page.
++ AutoLayout aLayout (pCurrentPage->GetAutoLayout());
++
++ // Find the entry of the menu for to the layout.
++ USHORT nItemCount (GetItemCount());
++ for (USHORT nId=1; nId<=nItemCount; nId++)
++ if (*static_cast<AutoLayout*>(GetItemData(nId)) == aLayout)
++ {
++ SelectItem(nId);
++ bItemSelected = true;
++ break;
++ }
++ }
++ while (false);
++
++ if ( ! bItemSelected)
++ SetNoSelection();
++}
++
++
++
++
++IMPL_LINK(LayoutMenu, EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*, pEvent)
++{
++ switch (pEvent->meEventId)
++ {
++ case ::sd::tools::EventMultiplexerEvent::EID_CURRENT_PAGE:
++ case ::sd::tools::EventMultiplexerEvent::EID_SLIDE_SORTER_SELECTION:
++ if ( ! mbSelectionUpdatePending)
++ UpdateSelection();
++ break;
++
++ case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_ADDED:
++ mbIsMainViewChangePending = true;
++ break;
++
++ case ::sd::tools::EventMultiplexerEvent::EID_MAIN_VIEW_REMOVED:
++ HideFocus();
++ break;
++
++ case ::sd::tools::EventMultiplexerEvent::EID_CONFIGURATION_UPDATED:
++ if (mbIsMainViewChangePending)
++ {
++ mbIsMainViewChangePending = false;
++ InvalidateContent();
++ }
++ break;
++
++ default:
++ /* Ignored */
++ break;
++ }
++
++ return 0;
++}
++
++
++
++
++void LayoutMenu::DataChanged (const DataChangedEvent& rEvent)
++{
++ Fill();
++ ValueSet::DataChanged(rEvent);
++}
++
++
++} } // end of namespace ::sd::toolpanel
diff -Nrup sd-m16/source/ui/toolpanel/LayoutMenu.hxx sd/source/ui/toolpanel/LayoutMenu.hxx
--- sd-m16/source/ui/toolpanel/LayoutMenu.hxx 2009-07-25 19:25:16.000000000 -0700
-+++ sd/source/ui/toolpanel/LayoutMenu.hxx 2009-07-31 00:10:16.000000000 -0700
++++ sd/source/ui/toolpanel/LayoutMenu.hxx 2009-08-04 23:40:41.000000000 -0700
@@ -39,6 +39,7 @@
#include "glob.hxx"
@@ -4038,6 +5275,246 @@ diff -Nrup sd-m16/source/ui/toolpanel/LayoutMenu.hxx sd/source/ui/toolpanel/Layo
/** Select the layout that is used by the current page.
*/
+diff -Nrup sd-m16/source/ui/toolpanel/LayoutMenu.hxx.orig sd/source/ui/toolpanel/LayoutMenu.hxx.orig
+--- sd-m16/source/ui/toolpanel/LayoutMenu.hxx.orig 1969-12-31 16:00:00.000000000 -0800
++++ sd/source/ui/toolpanel/LayoutMenu.hxx.orig 2009-08-04 23:23:46.000000000 -0700
+@@ -0,0 +1,236 @@
++/*************************************************************************
++ *
++ * 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: LayoutMenu.hxx,v $
++ * $Revision: 1.12 $
++ *
++ * This file is part of OpenOffice.org.
++ *
++ * OpenOffice.org is free software: you can redistribute it and/or modify
++ * it under the terms of the GNU Lesser General Public License version 3
++ * only, as published by the Free Software Foundation.
++ *
++ * OpenOffice.org is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU Lesser General Public License version 3 for more details
++ * (a copy is included in the LICENSE file that accompanied this code).
++ *
++ * You should have received a copy of the GNU Lesser General Public License
++ * version 3 along with OpenOffice.org. If not, see
++ * <http://www.openoffice.org/license.html>
++ * for a copy of the LGPLv3 License.
++ *
++ ************************************************************************/
++
++#ifndef SD_TASKPANE_LAYOUT_MENU_HXX
++#define SD_TASKPANE_LAYOUT_MENU_HXX
++
++#include "taskpane/TaskPaneTreeNode.hxx"
++
++#ifndef _COM_SUN_STAR_FRAME_XSTATUS_LISTENER_HPP_
++#include <com/sun/star/frame/XStatusListener.hpp>
++#endif
++
++#include "glob.hxx"
++#include "pres.hxx"
++#include "layoutlist.hxx"
++#include <vcl/ctrl.hxx>
++#include <svtools/valueset.hxx>
++#include <svtools/transfer.hxx>
++#include <sfx2/shell.hxx>
++
++
++class SfxModule;
++
++
++namespace sd {
++class DrawDocShell;
++class PaneManagerEvent;
++class ViewShellBase;
++}
++
++
++namespace sd { namespace tools {
++class EventMultiplexerEvent;
++} }
++
++
++namespace sd { namespace toolpanel {
++
++class ControlFactory;
++
++
++class LayoutMenu
++ : public ValueSet,
++ public TreeNode,
++ public SfxShell,
++ public DragSourceHelper,
++ public DropTargetHelper
++{
++public:
++ TYPEINFO();
++ SFX_DECL_INTERFACE(SD_IF_SDLAYOUTMENU)
++
++ /** Create a new layout menu. Depending on the given flag it
++ displays its own scroll bar or lets a surrounding window
++ handle that.
++ @param rDocumentShell
++ Used to determine writing direction.
++ @param rViewShellBase
++ Gives access to the view shell at whose active page the
++ layout will be set.
++ @param bUseOwnScrollBar
++ When <TRUE/> then we will show our own scroll bar when not
++ all icons can be displayed in the visible window area.
++ When <FALSE/> then rely on an outer scroll bar. In this
++ case we will set the height of the window so that all
++ icons are visible.
++ */
++ LayoutMenu (
++ TreeNode* pParent,
++ DrawDocShell& rDocumentShell,
++ ViewShellBase& rViewShellBase,
++ bool bUseOwnScrollBar);
++ virtual ~LayoutMenu (void);
++
++ static std::auto_ptr<ControlFactory> CreateControlFactory (
++ ViewShellBase& rBase,
++ DrawDocShell& rDocShell);
++
++ /** Return the name of the currently selected layout.
++ */
++ String GetSelectedLayoutName (void);
++
++ /** Return a numerical value representing the currently selected
++ layout.
++ */
++ AutoLayout GetSelectedAutoLayout (void);
++
++
++ // From ILayoutableWindow
++ virtual Size GetPreferredSize (void);
++ virtual sal_Int32 GetPreferredWidth (sal_Int32 nHeight);
++ virtual sal_Int32 GetPreferredHeight (sal_Int32 nWidth);
++ virtual sal_Int32 GetMinimumWidth (void);
++ virtual bool IsResizable (void);
++ virtual ::Window* GetWindow (void);
++
++ // From ::Window
++ virtual void Paint (const Rectangle& rRect);
++ virtual void Resize (void);
++
++ /** Show a context menu when the right mouse button is pressed.
++ */
++ virtual void MouseButtonDown (const MouseEvent& rEvent);
++
++ void Execute (SfxRequest& rRequest);
++ void GetState (SfxItemSet& rItemSet);
++
++ /** Call this method when the set of displayed layouts is not up-to-date
++ anymore. It will re-assemple this set according to the current
++ settings.
++ */
++ void InvalidateContent (void);
++
++ // DragSourceHelper
++ virtual void StartDrag (sal_Int8 nAction, const Point& rPosPixel);
++
++ // DropTargetHelper
++ virtual sal_Int8 AcceptDrop (const AcceptDropEvent& rEvent);
++ virtual sal_Int8 ExecuteDrop (const ExecuteDropEvent& rEvent);
++
++ /** The context menu is requested over this Command() method.
++ */
++ virtual void Command (const CommandEvent& rEvent);
++
++ /** Call Fill() when switching to or from high contrast mode so that the
++ correct set of icons is displayed.
++ */
++ virtual void DataChanged (const DataChangedEvent& rEvent);
++
++ using Window::GetWindow;
++ using ValueSet::StartDrag;
++
++private:
++ ViewShellBase& mrBase;
++
++ /** Do we use our own scroll bar or is viewport handling done by
++ our parent?
++ */
++ bool mbUseOwnScrollBar;
++
++ /** If we are asked for the preferred window size, then use this
++ many columns for the calculation.
++ */
++ const int mnPreferredColumnCount;
++
++ ::com::sun::star::uno::Reference<com::sun::star::frame::XStatusListener> mxListener;
++
++ bool mbSelectionUpdatePending;
++
++ bool mbIsMainViewChangePending;
++
++ /** Calculate the number of displayed rows. This depends on the given
++ item size, the given number of columns, and the size of the
++ control. Note that this is not the number of rows managed by the
++ valueset. This number may be larger. In that case a vertical
++ scroll bar is displayed.
++ */
++ int CalculateRowCount (const Size& rItemSize, int nColumnCount);
++
++ /** Fill the value set with the layouts that are applicable to the
++ current main view shell.
++ */
++ void Fill (void);
++
++ /** Remove all items from the value set.
++ */
++ void Clear (void);
++
++ /** Assign the given layout to all selected slides of a slide sorter.
++ If no slide sorter is active then this call is ignored. The slide
++ sorter in the center pane is preferred if the choice exists.
++ */
++ void AssignLayoutToSelectedSlides (sd::AutoLayout aLayout);
++
++ /** Insert a new page with the given layout. The page is inserted via
++ the main view shell, i.e. its SID_INSERTPAGE slot is called. It it
++ does not support this slot then inserting a new page does not take
++ place. The new page is inserted after the currently active one (the
++ one returned by ViewShell::GetActualPage().)
++ */
++ void InsertPageWithLayout (sd::AutoLayout aLayout);
++
++ /** Create a request structure that can be used with the SID_INSERTPAGE
++ and SID_MODIFYPAGE slots. The parameters are set so that the given
++ layout is assigned to the current page of the main view shell.
++ @param nSlotId
++ Supported slots are SID_INSERTPAGE and SID_MODIFYPAGE.
++ @param aLayout
++ Layout of the page to insert or to assign.
++ */
++ SfxRequest CreateRequest (
++ USHORT nSlotId,
++ sd::AutoLayout aLayout);
++
++ /** Select the layout that is used by the current page.
++ */
++ void UpdateSelection (void);
++
++ /** When clicked then set the current page of the view in the center pane.
++ */
++ DECL_LINK(ClickHandler, ValueSet*);
++ DECL_LINK(RightClickHandler, MouseEvent*);
++ DECL_LINK(StateChangeHandler, ::rtl::OUString*);
++ DECL_LINK(EventMultiplexerListener, ::sd::tools::EventMultiplexerEvent*);
++};
++
++} } // end of namespace ::sd::toolpanel
++
++#endif
diff -Nrup sd-m16/source/ui/unoidl/unopage.cxx sd/source/ui/unoidl/unopage.cxx
--- sd-m16/source/ui/unoidl/unopage.cxx 2009-07-25 19:25:14.000000000 -0700
+++ sd/source/ui/unoidl/unopage.cxx 2009-07-31 00:10:17.000000000 -0700
@@ -4253,8 +5730,8 @@ diff -Nrup sd-m16/test/export.map sd/test/export.map
+};
diff -Nrup sd-m16/test/layouttest.cxx sd/test/layouttest.cxx
--- sd-m16/test/layouttest.cxx 1969-12-31 16:00:00.000000000 -0800
-+++ sd/test/layouttest.cxx 2009-07-31 12:47:28.000000000 -0700
-@@ -0,0 +1,323 @@
++++ sd/test/layouttest.cxx 2009-08-04 21:31:21.000000000 -0700
+@@ -0,0 +1,371 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -4442,73 +5919,90 @@ diff -Nrup sd-m16/test/layouttest.cxx sd/test/layouttest.cxx
+ // insert your test code here.
+ void layoutListTest()
+ {
-+
-+ LayoutType* alayout1 = new LayoutType();
-+ LayoutType* alayout3;
-+ LayoutType* alayout2;
++ LayoutType* alayout1 = new LayoutType();
++ LayoutType* alayout2 = new LayoutType();
++ LayoutType* alayout3 = new LayoutType();
++ LayoutType* alayout4 = new LayoutType();
++ LayoutType* retlayout;
+ LayoutList* aTestList = new LayoutList(true);
+ Rectangle arect;
-+ sal_uInt32 listsize, layoutcnt;
-+ sal_uInt32 start_size = aTestList->length();
-+
-+ // set up a LayoutType
-+ LString name1(LString::CreateFromAscii("ateststring"));
-+ LString name2(LString::CreateFromAscii("anotherone"));
-+ LString name3(LString::CreateFromAscii("defaultname"));
-+
++ sal_Int32 listsize, layoutcnt, count, num;
++ sal_Int32 origsize, origcount, idx;
++ LString name1(LString::CreateFromAscii("name1"));
++ LString name2(LString::CreateFromAscii("name2"));
++ LString name3(LString::CreateFromAscii("name3"));
++ LString name4(LString::CreateFromAscii("name4"));
++
++ // set up layout 1
+ alayout1->setName(name1);
-+
+ alayout1->createDefaultElement();
+ alayout1->createDefaultElement();
+ alayout1->setPresKind(1, PRESOBJ_OUTLINE);
+
-+ // add the layout to the list at menu index 0
++ // add layout1 to the list at menu index 0
+ aTestList->addLayout(alayout1, 0, PK_STANDARD);
-+ alayout2 = aTestList->getLayoutByName(name1);
-+ CPPUNIT_ASSERT_MESSAGE("addlayout/getbyname/nolayout", alayout2);
-+ if(alayout2)
++ retlayout = aTestList->getLayoutByName(name1);
++ CPPUNIT_ASSERT_MESSAGE("addlayout1/getbyname/nolayout", retlayout);
++ if(retlayout)
++ {
++ CPPUNIT_ASSERT_MESSAGE("addlayout1/getbyname/samelayout", retlayout == alayout1);
++ }
++
++ // add layout2 to the list at menu index 1
++ alayout2->setName(name2);
++ alayout2->createDefaultElement();
++ alayout2->createDefaultElement();
++ alayout2->setPresKind(1, PRESOBJ_CHART);
++ aTestList->addLayout(alayout2, 1, PK_STANDARD);
++ retlayout = aTestList->getLayoutByName(name2);
++ CPPUNIT_ASSERT_MESSAGE("addlayout2/getbyname/nolayout", retlayout);
++ if(retlayout)
+ {
-+ CPPUNIT_ASSERT_MESSAGE("addlayout/getbyname/samelayout", alayout1 == alayout2);
++ CPPUNIT_ASSERT_MESSAGE("addlayout2/getbyname/samelayout", retlayout == alayout2);
+ }
+
-+ // get the layout out of the list
-+ alayout2 = aTestList->getLayoutByIndex(start_size);
-+ CPPUNIT_ASSERT_MESSAGE("getbyindex/nolayout", alayout2);
-+ if(alayout2)
++
++ // get the layout out of the list by index
++ retlayout = aTestList->getLayoutByIndex(0);
++ CPPUNIT_ASSERT_MESSAGE("getbyindex/nolayout", retlayout);
++ if(retlayout)
+ {
-+ CPPUNIT_ASSERT_MESSAGE("getbyindex/samelayout", alayout2->getName() == name1);
++ CPPUNIT_ASSERT_MESSAGE("getbyindex/samelayout", retlayout->getName() == name1);
+ }
+
+
+ // make sure a layout with the same name can't be added
-+ alayout3 = new LayoutType();
+ alayout3->setName(name1);
-+
-+ CPPUNIT_ASSERT_MESSAGE("insertsamename", !aTestList->addLayout(alayout3, 2, PK_STANDARD));
-+ // make sure a layout with a different name can be added
-+ alayout3->setName(name2);
-+
++ num = aTestList->addLayout(alayout3, 2, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("insertsamename", num == -1);
++
++ // add layout3 (add to end of menu list)
++ alayout3->setName(name3);
++ num = aTestList->addLayout(alayout3, -1, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("insert3rdlayout", num != -1);
++
++ // check size of list and compare with number of layouts
+ listsize = aTestList->length();
+ layoutcnt = aTestList->numberOfLayouts();
-+ CPPUNIT_ASSERT_MESSAGE("insertdiffname", aTestList->addLayout(alayout3, 1, PK_STANDARD));
++
+ // check list size and number of layouts.
-+ CPPUNIT_ASSERT_MESSAGE("listsize", (listsize+1) == aTestList->length());
-+ CPPUNIT_ASSERT_MESSAGE("remove/numberoflayouts", (layoutcnt+1) == aTestList->numberOfLayouts());
++ CPPUNIT_ASSERT_MESSAGE("listsize", 3 == aTestList->length());
++ CPPUNIT_ASSERT_MESSAGE("remove/numberoflayouts", 3 == aTestList->numberOfLayouts());
+
+ // test for get layout by name for the second layout
+
-+ alayout2 = aTestList->getLayoutByName(name2);
-+ CPPUNIT_ASSERT_MESSAGE("getbyname2/nolayout", alayout2);
-+ if(alayout2)
++ retlayout = aTestList->getLayoutByName(name2);
++ CPPUNIT_ASSERT_MESSAGE("getbyname2/nolayout", retlayout);
++ if(retlayout)
+ {
-+ CPPUNIT_ASSERT_MESSAGE("getbyname2/correct", alayout2->getName() == name2 );
++ CPPUNIT_ASSERT_MESSAGE("getbyname2/correct", retlayout->getName() == name2 );
+ }
+
+
+ // remove a layout from the list (number of layouts
+ // should be different from size of list)
-+ sal_uInt32 origsize = aTestList->length();
-+ sal_uInt32 origcount = aTestList->numberOfLayouts();
++ origsize = aTestList->length();
++ origcount = aTestList->numberOfLayouts();
+
+ aTestList->deleteLayoutFromList(name1);
+ layoutcnt = aTestList->numberOfLayouts();
@@ -4516,42 +6010,73 @@ diff -Nrup sd-m16/test/layouttest.cxx sd/test/layouttest.cxx
+ listsize = aTestList->length();
+ CPPUNIT_ASSERT_MESSAGE("remove/listlength", listsize == origsize);
+
-+ // test inserting a layout's index in the menu list
-+ alayout2 = aTestList->getLayoutAtMenuIndex(0, PK_STANDARD);
-+ CPPUNIT_ASSERT_MESSAGE("getLayoutMenuidx/nolayout", alayout2 );
-+ if(alayout2)
++ // get the layout (should be layout2) at 0 in the menu list.
++ retlayout = aTestList->getLayoutAtMenuIndex(0, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("getLayoutMenuidx/nolayout", retlayout );
++ if(retlayout)
+ {
-+ CPPUNIT_ASSERT_MESSAGE("getlayoutmenuidx/correct", alayout2->getName() == alayout3->getName() );
++ CPPUNIT_ASSERT_MESSAGE("getlayoutmenuidx/correct", retlayout->getName() == alayout2->getName() );
++ }
++
++ // get the layout (should be layout3) at 1 in the menu list.
++ retlayout = aTestList->getLayoutAtMenuIndex(1, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("getLayoutMenuidx/nolayout", retlayout );
++ if(retlayout)
++ {
++ CPPUNIT_ASSERT_MESSAGE("getlayoutmenuidx/correct", retlayout->getName() == alayout3->getName() );
+ }
+
-+ // add layout1 back at menu 2
-+ alayout1 = new LayoutType();
-+ alayout1->setName(name1);
-+ aTestList->addLayout(alayout1, 2, PK_STANDARD);
-+ sal_uInt32 num = aTestList->getLayoutIndex(name1);
++ // add layout4 in the list(see if it inserts in the 'hole' at 0)
++ // put in different menu list from the rest.
++ alayout4->setName(name4);
++ aTestList->addLayout(alayout4, -1, PK_HANDOUT);
++ num = aTestList->getLayoutIndex(name4);
+ CPPUNIT_ASSERT_MESSAGE("re-add/correct", num == 0 );
+
-+
+ // test the length of a menu list
-+ sal_uInt32 count = aTestList->getMenuLength(PK_HANDOUT);
-+ CPPUNIT_ASSERT_MESSAGE("getMenuLength", count = 6);
-+
-+
++ count = aTestList->getMenuLength(PK_HANDOUT);
++ CPPUNIT_ASSERT_MESSAGE("getMenuLength1", count == 1);
++ count = aTestList->getMenuLength(PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("getMenuLength2", count == 2);
+
-+ // get a layout's index at the given menu index
-+ // this is for layout3
-+ sal_uInt32 idx = aTestList->getMenuIndex(3, PK_STANDARD);
-+ CPPUNIT_ASSERT_MESSAGE("getMenuIndex", idx = 1);
++ // get a layout's menu index at the given layout index
++ // this is for layout2 (layout idx is 1, menu is 0)
++ num = aTestList->getMenuIndex(1, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("getMenuIndex2", num == 0);
++ // this is for layout3 (idx is 2, menu is 1)
++ num = aTestList->getMenuIndex(2, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("getMenuIndex3", num == 1);
++ // this is for layout4 (idx is 0, menu is 0)
++ idx = aTestList->getMenuIndex(0, PK_HANDOUT);
++ CPPUNIT_ASSERT_MESSAGE("getMenuIndex4", idx == 0);
+
-+ //remove the layout from the menu
++ //remove the layout from the menu (layout2 is 1)
+ aTestList->removeFromMenuList(1, PK_STANDARD);
-+ CPPUNIT_ASSERT_MESSAGE("removeMenuIndex", idx = 1);
++ // should moved layout3 (idx=2) up to 0 menu position
++ idx = aTestList->getMenuIndex(2, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("removeMenuIndex", idx == 0);
+
-+ // add a layout to the menu list
-+ aTestList->addToMenuList(0, 6, PK_STANDARD);
-+ CPPUNIT_ASSERT_MESSAGE("addtoMenu", idx = 1);
-+
-+
++ // add a layout to the menu list (larger index than
++ // the size of the menu list). should put in back of list
++ aTestList->addToMenuList(6, 0, PK_STANDARD);
++ idx = aTestList->getMenuIndex(0, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("addtoMenu1", idx == 1 );
++
++ // add a layout to the menu list at 1
++ aTestList->addToMenuList(1, 10, PK_STANDARD);
++ idx = aTestList->getMenuIndex(10, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("addtoMenu2", idx == 1 );
++
++ // add a layout to the menu list at 1, the
++ // layout above should now be at 2
++ aTestList->addToMenuList(1, 8, PK_STANDARD);
++ idx = aTestList->getMenuIndex(10, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("addtoMenu3", idx == 2 );
++
++ // change layout at 0 to another menu index
++ aTestList->moveLayoutInMenu(2, 0, PK_STANDARD);
++ idx = aTestList->getMenuIndex(0, PK_STANDARD);
++ CPPUNIT_ASSERT_MESSAGE("moveInMenu", idx == 2 );
+
+ }
+
More information about the ooo-build-commit
mailing list