diff options
author | Vishv Brahmbhatt <vishvbrahmbhatt19@gmail.com> | 2013-07-31 01:58:58 +0530 |
---|---|---|
committer | Thorsten Behrens <tbehrens@suse.com> | 2013-08-26 14:47:24 +0200 |
commit | 7885ead7ee4ed8858655001bedd1b312c03a452b (patch) | |
tree | 777facc620144f925da299b5dc63755ffb1a2bdf | |
parent | 52abaef5db0dd1a7e55874b5d7e92fa378379906 (diff) |
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
-rw-r--r-- | sd/inc/drawdoc.hxx | 6 | ||||
-rw-r--r-- | sd/source/core/drawdoc.cxx | 88 | ||||
-rw-r--r-- | sd/xml/layoutlist.xml | 22 |
3 files changed, 104 insertions, 12 deletions
diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx index f33cfdedaeb4..58736028422c 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> @@ -188,6 +189,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; @@ -262,6 +264,9 @@ public: bool IsExitAfterPresenting() const; void SetExitAfterPresenting( bool bExitAfterPresenting ); + 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 @@ -307,7 +312,6 @@ public: Whether the replace operation should take the name from the new page, or preserve the old name */ - sal_Bool InsertBookmarkAsPage(const std::vector<OUString> &rBookmarkList, std::vector<OUString> *pExchangeList, sal_Bool bLink, sal_Bool bReplace, sal_uInt16 nPgPos, diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 60fa917a0bc3..9f56101a14c6 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -61,6 +61,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" @@ -89,6 +105,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) @@ -988,4 +1012,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 82424b071481..727e5a8bb86a 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"/> |