Tag: cws_src680_reportdesign02
User: oj      
Date: 2007-11-07 12:14:23+0000
Modified:
   dba/dbaccess/source/core/dataaccess/documentdefinition.cxx
   dba/dbaccess/source/core/dataaccess/documentdefinition.hxx
   dba/dbaccess/source/core/dataaccess/intercept.cxx
   dba/dbaccess/source/ui/app/AppControllerGen.cxx

Log:
 #i78387# new menu entry for saveas for reports

File Changes:

Directory: /dba/dbaccess/source/core/dataaccess/
================================================

File [changed]: documentdefinition.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.cxx?r1=1.47.22.1&r2=1.47.22.2
Delta lines:  +110 -4
---------------------
--- documentdefinition.cxx      2007-10-26 11:05:05+0000        1.47.22.1
+++ documentdefinition.cxx      2007-11-07 12:14:20+0000        1.47.22.2
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: documentdefinition.cxx,v $
  *
- *  $Revision: 1.47.22.1 $
+ *  $Revision: 1.47.22.2 $
  *
- *  last change: $Author: oj $ $Date: 2007/10/26 11:05:05 $
+ *  last change: $Author: oj $ $Date: 2007/11/07 12:14:20 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -1209,6 +1209,112 @@
        return sal_True;
 }
 // 
-----------------------------------------------------------------------------
+sal_Bool ODocumentDefinition::saveAs()
+{
+       // default handling: instantiate an interaction handler and let it 
handle the parameter request
+    if ( !m_bOpenInDesign )
+        return sal_False;
+       try
+       {
+               {
+                       ::vos::OGuard aSolarGuard(Application::GetSolarMutex());
+
+                       // the request
+                       Reference<XNameAccess> 
xName(m_xParentContainer,UNO_QUERY);
+                       DocumentSaveRequest aRequest;
+                       aRequest.Name = m_pImpl->m_aProps.aTitle;
+                       if ( !aRequest.Name.getLength() )
+                       {
+                               if ( m_bForm )
+                                       aRequest.Name = DBACORE_RESSTRING( 
RID_STR_FORM );
+                               else
+                                       aRequest.Name = DBACORE_RESSTRING( 
RID_STR_REPORT );
+                               aRequest.Name = 
::dbtools::createUniqueName(xName,aRequest.Name);
+                       }
+
+                       aRequest.Content.set(m_xParentContainer,UNO_QUERY);
+                       OInteractionRequest* pRequest = new 
OInteractionRequest(makeAny(aRequest));
+                       Reference< XInteractionRequest > xRequest(pRequest);
+                       // some knittings
+                       // two continuations allowed: OK and Cancel
+                       ODocumentSaveContinuation* pDocuSave = new 
ODocumentSaveContinuation;
+                       pRequest->addContinuation(pDocuSave);
+                       OInteraction< XInteractionDisapprove >* pDisApprove = 
new OInteraction< XInteractionDisapprove >;
+                       pRequest->addContinuation(pDisApprove);
+                       OInteractionAbort* pAbort = new OInteractionAbort;
+                       pRequest->addContinuation(pAbort);
+
+                       // create the handler, let it handle the request
+                       Reference< XInteractionHandler > 
xHandler(m_xORB->createInstance(SERVICE_SDB_INTERACTION_HANDLER), UNO_QUERY);
+                       if ( xHandler.is() )
+                               xHandler->handle(xRequest);
+
+                       if ( pAbort->wasSelected() )
+                               return sal_False;
+                       if  ( pDisApprove->wasSelected() )
+                               return sal_True;
+                       if ( pDocuSave->wasSelected() )
+                       {
+                               ::osl::MutexGuard aGuard(m_aMutex);
+                               Reference<XNameContainer> 
xNC(pDocuSave->getContent(),UNO_QUERY);
+                               if ( xNC.is() )
+                               {
+                    try
+                    {
+                        Reference< XStorage> xStorage = getStorage();
+                               const static ::rtl::OUString 
sBaseName(RTL_CONSTASCII_USTRINGPARAM("Obj"));
+                                   // 
-----------------------------------------------------------------------------
+                                   Reference<XNameAccess> 
xElements(xStorage,UNO_QUERY_THROW);
+                                   ::rtl::OUString sPersistentName = 
::dbtools::createUniqueName(xElements,sBaseName);
+                        
xStorage->copyElementTo(m_pImpl->m_aProps.sPersistentName,xStorage,sPersistentName);
+
+                        ::rtl::OUString sOldName = m_pImpl->m_aProps.aTitle;
+                        rename(pDocuSave->getName());
+                        updateDocumentTitle();
+        
+                        Sequence< Any > aArguments(3);
+                               PropertyValue aValue;
+                               // set as folder
+                               aValue.Name = PROPERTY_NAME;
+                               aValue.Value <<= sOldName;
+                               aArguments[0] <<= aValue;
+
+                               aValue.Name = PROPERTY_PERSISTENT_NAME;
+                               aValue.Value <<= sPersistentName;
+                               aArguments[1] <<= aValue;
+
+                               aValue.Name = PROPERTY_AS_TEMPLATE;
+                               aValue.Value <<= m_pImpl->m_aProps.bAsTemplate;
+                               aArguments[2] <<= aValue;
+
+                                   Reference< XMultiServiceFactory > xORB( 
m_xParentContainer, UNO_QUERY_THROW );
+                                   Reference< XInterface > xComponent( 
xORB->createInstanceWithArguments( SERVICE_SDB_DOCUMENTDEFINITION, aArguments ) 
);
+                                   Reference< XNameContainer > xNameContainer( 
m_xParentContainer, UNO_QUERY_THROW );
+                                   xNameContainer->insertByName( sOldName, 
makeAny( xComponent ) );
+                           }
+                           catch(Exception&)
+                           {
+                        DBG_UNHANDLED_EXCEPTION();
+                           }
+                               }
+                       }
+               }
+
+               ::osl::MutexGuard aGuard(m_aMutex);
+               Reference<XEmbedPersist> xPersist(m_xEmbeddedObject,UNO_QUERY);
+               if ( xPersist.is() )
+               {
+                       xPersist->storeOwn();
+                       notifyDataSourceModified();
+               }
+       }
+       catch(Exception&)
+       {
+               OSL_ENSURE(0,"ODocumentDefinition::save: caught an Exception 
(tried to let the InteractionHandler handle it)!");
+       }
+       return sal_True;
+}
+// 
-----------------------------------------------------------------------------
 void ODocumentDefinition::fillLoadArgs(Sequence<PropertyValue>& 
_rArgs,Sequence<PropertyValue>& _rEmbeddedObjectDescriptor,const 
Reference<XConnection>& _xConnection,sal_Bool _bReadOnly,sal_Int16 
_nMarcoExcecMode)
 {
        sal_Int32 nLen = _rArgs.getLength();

File [changed]: documentdefinition.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/documentdefinition.hxx?r1=1.23&r2=1.23.24.1
Delta lines:  +5 -3
-------------------
--- documentdefinition.hxx      2007-09-26 14:40:32+0000        1.23
+++ documentdefinition.hxx      2007-11-07 12:14:20+0000        1.23.24.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: documentdefinition.hxx,v $
  *
- *  $Revision: 1.23 $
+ *  $Revision: 1.23.24.1 $
  *
- *  last change: $Author: hr $ $Date: 2007/09/26 14:40:32 $
+ *  last change: $Author: oj $ $Date: 2007/11/07 12:14:20 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -182,9 +182,11 @@
        virtual ::com::sun::star::uno::Reference< 
::com::sun::star::embed::XStorage> getStorage() const;
 
        sal_Bool save(sal_Bool _bApprove);
+    sal_Bool saveAs();
        void closeObject();
        sal_Bool isModified();
        void fillReportData(sal_Bool _bFill = sal_True);
+    inline sal_Bool isNewReport() const { return !m_bForm && 
!m_pImpl->m_aProps.bAsTemplate; }
 
     /** prepares closing the document component
 

File [changed]: intercept.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/dataaccess/intercept.cxx?r1=1.8&r2=1.8.166.1
Delta lines:  +44 -33
---------------------
--- intercept.cxx       2006-09-17 06:40:38+0000        1.8
+++ intercept.cxx       2007-11-07 12:14:20+0000        1.8.166.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: intercept.cxx,v $
  *
- *  $Revision: 1.8 $
+ *  $Revision: 1.8.166.1 $
  *
- *  last change: $Author: obo $ $Date: 2006/09/17 06:40:38 $
+ *  last change: $Author: oj $ $Date: 2007/11/07 12:14:20 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -158,6 +158,12 @@
                }
                else if( _URL.Complete == m_aInterceptedURL[DISPATCH_SAVEAS] )
                {
+            if ( m_pContentHolder->isNewReport() )
+            {
+                m_pContentHolder->saveAs();
+            }
+            else
+            {
                        Sequence< PropertyValue > aNewArgs = Arguments;
                        sal_Int32 nInd = 0;
 
@@ -183,6 +189,7 @@
                        if ( xDispatch.is() )
                                xDispatch->dispatch( _URL, aNewArgs );
                }
+               }
                else if (  _URL.Complete == m_aInterceptedURL[DISPATCH_CLOSEDOC]
                                || _URL.Complete == 
m_aInterceptedURL[DISPATCH_CLOSEWIN]
                                || _URL.Complete == 
m_aInterceptedURL[DISPATCH_CLOSEFRAME]
@@ -219,6 +226,9 @@
 
        if ( m_pContentHolder && _URL.Complete == 
m_aInterceptedURL[DISPATCH_SAVEAS] )
        {   // SaveAs
+        
+        if ( !m_pContentHolder->isNewReport() )
+        {
                FeatureStateEvent aStateEvent;
                aStateEvent.FeatureURL.Complete = 
m_aInterceptedURL[DISPATCH_SAVEAS];
                aStateEvent.FeatureDescriptor = 
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SaveCopyTo"));
@@ -226,6 +236,7 @@
                aStateEvent.Requery = sal_False;
                aStateEvent.State <<= (rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("($3)")));
                Control->statusChanged(aStateEvent);
+        }              
 
                {
                        osl::MutexGuard aGuard(m_aMutex);

Directory: /dba/dbaccess/source/ui/app/
=======================================

File [changed]: AppControllerGen.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppControllerGen.cxx?r1=1.28&r2=1.28.24.1
Delta lines:  +37 -6
--------------------
--- AppControllerGen.cxx        2007-09-26 14:46:50+0000        1.28
+++ AppControllerGen.cxx        2007-11-07 12:14:21+0000        1.28.24.1
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: AppControllerGen.cxx,v $
  *
- *  $Revision: 1.28 $
+ *  $Revision: 1.28.24.1 $
  *
- *  last change: $Author: hr $ $Date: 2007/09/26 14:46:50 $
+ *  last change: $Author: oj $ $Date: 2007/11/07 12:14:21 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -356,15 +356,37 @@
 {
        ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
        ::osl::MutexGuard aGuard(m_aMutex);
-       m_bNeedToReconnect = sal_True;
        if ( evt.PropertyName == PROPERTY_USER )
+    {
+        m_bNeedToReconnect = sal_True;
                InvalidateFeature(SID_DB_APP_STATUS_USERNAME);
+    }
        else if ( evt.PropertyName == PROPERTY_URL )
        {
+        m_bNeedToReconnect = sal_True;
                InvalidateFeature(SID_DB_APP_STATUS_DBNAME);
                InvalidateFeature(SID_DB_APP_STATUS_TYPE);
                InvalidateFeature(SID_DB_APP_STATUS_HOSTNAME);
        }
+    else if ( PROPERTY_NAME == evt.PropertyName )
+    {
+        const ElementType eType = getContainer()->getElementType();
+        if ( eType == E_FORM || eType == E_REPORT )
+               {
+            ::rtl::OUString sOldName,sNewName;
+            evt.OldValue >>= sOldName;
+            evt.NewValue >>= sNewName;
+            Reference<XChild> xChild(evt.Source,UNO_QUERY);
+            if ( xChild.is() )
+            {
+                Reference<XContent> xContent(xChild->getParent(),UNO_QUERY);
+                           if ( xContent.is() )
+                                   sOldName = 
xContent->getIdentifier()->getContentIdentifier() + 
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + sOldName;
+            }
+            
+            getContainer()->elementReplaced( eType , sOldName, sNewName );
+        }
+    }
 
        EventObject aEvt;
        aEvt.Source = m_xModel;
@@ -656,9 +678,18 @@
 {
        if ( _xDocument.is() )
        {
+        try
+        {
+            Reference<XPropertySet> xProp(_xDefintion,UNO_QUERY_THROW);
+            if ( xProp->getPropertySetInfo()->hasPropertyByName(PROPERTY_NAME) 
)
+                
xProp->addPropertyChangeListener(PROPERTY_NAME,static_cast<XPropertyChangeListener*>(this));
                m_aDocuments[_xDocument] = _xDefintion;
                
_xDocument->addEventListener(static_cast<XFrameActionListener*>(this));
        }
+               catch(Exception&)
+               {
+               }
+       }
 }
 // 
-----------------------------------------------------------------------------
 sal_Bool OApplicationController::insertHierachyElement(ElementType 
_eType,const String& _sParentFolder,sal_Bool _bCollection,const 
Reference<XContent>& _xContent,sal_Bool _bMove)




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to