sd/inc/drawdoc.hxx         |    5 ++
 sd/source/core/drawdoc.cxx |   88 +++++++++++++++++++++++++++++++++++++++++++++
 sd/xml/layoutlist.xml      |   22 +++++------
 3 files changed, 103 insertions(+), 12 deletions(-)

New commits:
commit b51863296598dc9fe90af07bb8288d13652f1d72
Author: Vishv Brahmbhatt <vishvbrahmbhat...@gmail.com>
Date:   Wed Jul 31 01:58:58 2013 +0530

    Temporarily adding new methods to "drawdoc.cxx".
    
    Adding new methods to "SdDrawDocument" class to set the vector "layoutlist"
    from the constructor of "SdDrawDocument" and use it in 
"CalcAutoLayoutRectangles".
    Build got failed in-between,so authentication of it's working is left to be 
done.
    
    Change-Id: Ia614ab0e1d45022d770e61d27b0ae6c74dc71bf8

diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx
index 77ac6b6..066cc1a 100644
--- a/sd/inc/drawdoc.hxx
+++ b/sd/inc/drawdoc.hxx
@@ -30,6 +30,7 @@
 #include <unotools/charclass.hxx>
 #include <sot/storage.hxx>
 #include <rsc/rscsfx.hxx>
+#include <com/sun/star/xml/dom/XNode.hpp>
 
 #include <svx/svdundo.hxx>
 
@@ -187,6 +188,7 @@ private:
                         DECL_LINK(OnlineSpellEventHdl, EditStatus*);
 
     std::vector< OUString > maAnnotationAuthors;
+    
std::vector<com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode>> 
layoutinfo;
 
     bool                mbUseEmbedFonts;
 
@@ -257,7 +259,8 @@ public:
 
     bool IsStartWithPresentation() const;
     void SetStartWithPresentation( bool bStartWithPresentation );
-
+    void SetLayoutVector();
+    
std::vector<com::sun::star::uno::Reference<com::sun::star::xml::dom::XNode>> 
GetLayoutVector();
     /** Insert pages into this document
 
         This method inserts whole pages into this document, either
diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx
index aca4996..ca12a96 100644
--- a/sd/source/core/drawdoc.cxx
+++ b/sd/source/core/drawdoc.cxx
@@ -62,6 +62,22 @@
 #include <unotools/pathoptions.hxx>
 #include <unotools/lingucfg.hxx>
 #include <unotools/linguprops.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
+#include <com/sun/star/xml/dom/XDocument.hpp>
+#include <com/sun/star/xml/dom/XNode.hpp>
+#include <com/sun/star/xml/dom/XNodeList.hpp>
+#include <com/sun/star/xml/dom/XNamedNodeMap.hpp>
+#include <com/sun/star/xml/dom/DocumentBuilder.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/util/theMacroExpander.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/configuration/theDefaultProvider.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <rtl/ustring.hxx>
+#include <rtl/uri.hxx>
+#include <unotools/ucbstreamhelper.hxx>
 
 #include <editeng/outliner.hxx>
 #include "drawdoc.hxx"
@@ -90,6 +106,13 @@ using namespace ::com::sun::star::uno;
 using namespace ::com::sun::star::lang;
 using namespace ::com::sun::star::linguistic2;
 
+using namespace com::sun::star::xml::dom;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::io::XInputStream;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::container::XNameAccess;
+using ::com::sun::star::beans::PropertyValue;
+
 //////////////////////////////////////////////////////////////////////////////
 
 TYPEINIT1( SdDrawDocument, FmFormModel );
@@ -169,6 +192,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, 
SfxObjectShell* pDrDocSh)
     mpMasterPageListWatcher = ::std::auto_ptr<ImpMasterPageListWatcher>(
         new ImpMasterPageListWatcher(*this));
 
+    SetLayoutVector();
     SetObjectShell(pDrDocSh);       // for VCDrawModel
 
     if (mpDocSh)
@@ -978,4 +1002,68 @@ sal_uInt16 SdDrawDocument::GetAnnotationAuthorIndex( 
const OUString& rAuthor )
     return idx;
 }
 
+#define EXPAND_PROTOCOL "vnd.sun.star.expand:"
+// to get the root element of the xml file
+Reference<XElement> getRoot()
+{
+    const Reference<css::uno::XComponentContext> 
xContext(comphelper_getProcessComponentContext());
+    Reference< XMultiServiceFactory > 
xServiceFactory(xContext->getServiceManager(), UNO_QUERY_THROW );
+    Reference< util::XMacroExpander > xMacroExpander 
=util::theMacroExpander::get(xContext);
+    Reference< XMultiServiceFactory > xConfigProvider 
=configuration::theDefaultProvider::get( xContext );
+
+    Any propValue = uno::makeAny(
+        beans::PropertyValue(
+            "nodepath", -1,
+            uno::makeAny( OUString( "/org.openoffice.Office.Impress/Misc" )),
+            beans::PropertyState_DIRECT_VALUE ) );
+
+    Reference<container::XNameAccess> xNameAccess(
+        xConfigProvider->createInstanceWithArguments(
+            "com.sun.star.configuration.ConfigurationAccess",
+            Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW );
+    Sequence< rtl::OUString > aFiles;
+    xNameAccess->getByName( "LayoutListFiles" ) >>= aFiles;
+    rtl::OUString aURL;
+    for( sal_Int32 i=0; i<aFiles.getLength(); ++i )
+    {
+        aURL = aFiles[i];
+        if( aURL.startsWith( EXPAND_PROTOCOL ) )
+        {
+            // cut protocol
+            rtl::OUString aMacro( aURL.copy( sizeof ( EXPAND_PROTOCOL ) -1 ) );
+            // decode uric class chars
+            aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, 
RTL_TEXTENCODING_UTF8 );
+            // expand macro string
+            aURL = xMacroExpander->expandMacros( aMacro );
+        }
+    }
+    if( aURL.startsWith( "file://" ) )
+    {
+        rtl::OUString aSysPath;
+        if( osl_getSystemPathFromFileURL( aURL.pData, &aSysPath.pData ) == 
osl_File_E_None )
+            aURL = aSysPath;
+    }
+    const Reference<XDocumentBuilder> 
xDocBuilder(css::xml::dom::DocumentBuilder::create(comphelper::getComponentContext(xServiceFactory)));
+    const Reference<XDocument> xDoc = xDocBuilder->parseURI(aURL);
+    const Reference<XElement> xRoot = xDoc->getDocumentElement();
+    return xRoot;//this loops seems to work only once,so temporary returning 
the root element
+}
+
+void SdDrawDocument::SetLayoutVector()
+{
+    int layoutlistsize;
+    const Reference<XElement> root= getRoot();//get the root element of my xml 
file
+    const Reference<XNodeList> layoutlist = 
root->getElementsByTagName("layout");
+    layoutlistsize=layoutlist->getLength();
+    for(int index=0; index<layoutlistsize ;index++)
+    {
+        Reference<XNode> layoutnode = layoutlist->item(index);      //get i'th 
layout element
+        layoutinfo.push_back(layoutnode);
+    }
+}
+
+std::vector<Reference<XNode>> GetLayoutVector()
+{
+    return layoutinfo;
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/xml/layoutlist.xml b/sd/xml/layoutlist.xml
index 82424b0..727e5a8 100644
--- a/sd/xml/layoutlist.xml
+++ b/sd/xml/layoutlist.xml
@@ -18,20 +18,20 @@
     </layout>
     <layout type="AUTOLAYOUT_TITLE_CONTENT_2CONTENT">
         <presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" 
layout-size-height="3507" layout-size-width="25200"/>
-        <presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="12297" layout-size-width="12180"/>
-        <presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="14311" 
layout-pos-y="4914" layout-size-height="12297" layout-size-width="5809"/>
-        <presobj kind="PRESOBJ_OUTLINE3" layout-pos-x="14311" 
layout-pos-y="11274" layout-size-height="12297" layout-size-width="5809"/>
+        <presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="12180" layout-size-width="12297"/>
+        <presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="14311" 
layout-pos-y="4914" layout-size-height="5809" layout-size-width="12297"/>
+        <presobj kind="PRESOBJ_OUTLINE3" layout-pos-x="14311" 
layout-pos-y="11274" layout-size-height="5809" layout-size-width="12297"/>
     </layout>
     <layout type="AUTOLAYOUT_TITLE_4CONTENT">
         <presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" 
layout-size-height="3507" layout-size-width="25200"/>
-        <presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="5809" layout-size-width="12297"/>
-        <presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="14311" 
layout-pos-y="5914" layout-size-height="4509" layout-size-width="12297"/>
-        <presobj kind="PRESOBJ_OUTLINE3" layout-pos-x="14311" 
layout-pos-y="12274" layout-size-height="4509" layout-size-width="12297"/>
-        <presobj kind="PRESOBJ_OUTLINE4" layout-pos-x="1400" 
layout-pos-y="11274" layout-size-height="5809" layout-size-width="12297"/>
+        <presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="12180" layout-size-width="25200"/>
+        <presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="12180" layout-size-width="25200"/>
+        <presobj kind="PRESOBJ_OUTLINE3" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="12180" layout-size-width="25200"/>
+        <presobj kind="PRESOBJ_OUTLINE4" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="12180" layout-size-width="25200"/>
     </layout>
     <layout type="AUTOLAYOUT_ONLY_TEXT">
         <presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" 
layout-pos-y="837" layout-size-height="25200" layout-size-width="16256"/>
-     </layout>
+    </layout>
     <layout type="AUTOLAYOUT_TITLE_ONLY">
         <presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" 
layout-size-height="3507" layout-size-width="25200"/>
     </layout>
@@ -50,9 +50,9 @@
     </layout>
     <layout type="AUTOLAYOUT_TITLE_2CONTENT_CONTENT">
         <presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" 
layout-size-height="3507" layout-size-width="25200"/>
-        <presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="12297" layout-size-width="5809"/>
-        <presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="1400" 
layout-pos-y="11274" layout-size-height="12297" layout-size-width="5809"/>
-        <presobj kind="PRESOBJ_OUTLINE3" layout-pos-x="14311" 
layout-pos-y="4914" layout-size-height="12297" layout-size-width="12180"/>
+        <presobj kind="PRESOBJ_OUTLINE1" layout-pos-x="1400" 
layout-pos-y="4914" layout-size-height="5809" layout-size-width="12297"/>
+        <presobj kind="PRESOBJ_OUTLINE2" layout-pos-x="1400" 
layout-pos-y="11274" layout-size-height="5809" layout-size-width="12297">
+        <presobj kind="PRESOBJ_OUTLINE3" layout-pos-x="14311" 
layout-pos-y="4914" layout-size-height="12180" layout-size-width="12297"/>
     </layout>
     <layout type="AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT">
         <presobj kind="PRESOBJ_TITLE" layout-pos-x="1400" layout-pos-y="837" 
layout-size-height="3507" layout-size-width="25200"/>
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to