summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2011-03-23 16:59:26 +0100
committerJan Holesovsky <kendy@suse.cz>2011-03-23 16:59:26 +0100
commit3b7ab82aee60aec1e47c1e253d3977a3fc011f5b (patch)
tree1ebee7adb28ba3175deee3948aee8f5489d9b509 /sfx2
parent486dd9082e177aa63294f76d6a75b08dde5957e5 (diff)
parent61879c218dd0e6e94884e7c6e06e3c5c18540b4a (diff)
Merge commit 'ooo/DEV300_m103'
Conflicts: basic/source/runtime/makefile.mk basic/source/runtime/step2.cxx desktop/prj/build.lst desktop/source/app/app.cxx desktop/source/deployment/registry/dp_backend.cxx drawinglayer/source/attribute/fontattribute.cxx editeng/inc/editeng/fontitem.hxx editeng/source/editeng/edtspell.cxx editeng/source/misc/svxacorr.cxx framework/inc/services/substitutepathvars.hxx framework/source/services/substitutepathvars.cxx sfx2/qa/cppunit/makefile.mk sfx2/source/doc/SfxDocumentMetaData.cxx sfx2/source/doc/objxtor.cxx svx/source/dialog/svxruler.cxx sysui/desktop/icons/so9_base_app.ico sysui/desktop/icons/so9_calc_app.ico sysui/desktop/icons/so9_draw_app.ico sysui/desktop/icons/so9_impress_app.ico sysui/desktop/icons/so9_main_app.ico sysui/desktop/icons/so9_math_app.ico sysui/desktop/icons/so9_writer_app.ico xmlhelp/source/cxxhelp/provider/databases.cxx xmlhelp/source/cxxhelp/provider/db.cxx xmlhelp/source/cxxhelp/provider/db.hxx
Diffstat (limited to 'sfx2')
-rwxr-xr-xsfx2/inc/sfx2/module.hxx12
-rwxr-xr-xsfx2/qa/unoapi/makefile.mk48
-rwxr-xr-xsfx2/source/appl/module.cxx34
-rwxr-xr-xsfx2/source/doc/SfxDocumentMetaData.cxx44
-rwxr-xr-xsfx2/source/doc/objxtor.cxx5
-rwxr-xr-xsfx2/source/view/viewprn.cxx83
6 files changed, 197 insertions, 29 deletions
diff --git a/sfx2/inc/sfx2/module.hxx b/sfx2/inc/sfx2/module.hxx
index 88da2166f8e7..4dcd035fd49f 100755
--- a/sfx2/inc/sfx2/module.hxx
+++ b/sfx2/inc/sfx2/module.hxx
@@ -35,6 +35,7 @@
#include <sfx2/imgdef.hxx>
#include <sal/types.h>
#include <tools/fldunit.hxx>
+#include <com/sun/star/uno/Reference.hxx>
class ImageList;
@@ -57,6 +58,9 @@ class SfxStbCtrlFactArr_Impl;
class SfxTabPage;
class Window;
+namespace com { namespace sun { namespace star { namespace frame {
+ class XFrame;
+} } } }
//====================================================================
class SFX2_DLLPUBLIC SfxModule : public SfxShell
@@ -96,6 +100,14 @@ public:
static SfxModule* GetActiveModule( SfxViewFrame* pFrame=NULL );
static FieldUnit GetCurrentFieldUnit();
+ /** retrieves the field unit of the module belonging to the document displayed in the given frame
+
+ Effectively, this method looks up the SfxViewFrame belonging to the given XFrame, then the SfxModule belonging to
+ the document in this frame, then this module's field unit.
+
+ Failures in any of those steps are reported as assertion in non-product builds, and then FUNIT_100TH_MM is returned.
+ */
+ static FieldUnit GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & i_frame );
FieldUnit GetFieldUnit() const;
SAL_DLLPRIVATE static SfxModuleArr_Impl& GetModules_Impl();
diff --git a/sfx2/qa/unoapi/makefile.mk b/sfx2/qa/unoapi/makefile.mk
new file mode 100755
index 000000000000..ea91ba4d1c44
--- /dev/null
+++ b/sfx2/qa/unoapi/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#***********************************************************************/
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../..
+PRJNAME = sfx2
+TARGET = qa_unoapi
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = org/openoffice/sfx2/qa/unoapi
+JAVATESTFILES = Test.java
+JAVAFILES = $(JAVATESTFILES)
+JARFILES = OOoRunner.jar ridl.jar test.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx
index 1a92d59ea464..62e7f0547808 100755
--- a/sfx2/source/appl/module.cxx
+++ b/sfx2/source/appl/module.cxx
@@ -49,6 +49,7 @@
#include <svl/intitem.hxx>
#include "sfx2/taskpane.hxx"
#include <tools/diagnose_ex.h>
+#include <rtl/strbuf.hxx>
#define SfxModule
#include "sfxslots.hxx"
@@ -399,6 +400,39 @@ SfxModule* SfxModule::GetActiveModule( SfxViewFrame* pFrame )
return pSh ? pSh->GetModule() : 0;
}
+FieldUnit SfxModule::GetModuleFieldUnit( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > const & i_frame )
+{
+ ENSURE_OR_RETURN( i_frame.is(), "SfxModule::GetModuleFieldUnit: invalid frame!", FUNIT_100TH_MM );
+
+ // find SfxViewFrame for the given XFrame
+ SfxViewFrame* pViewFrame = SfxViewFrame::GetFirst();
+ while ( pViewFrame != NULL )
+ {
+ if ( pViewFrame->GetFrame().GetFrameInterface() == i_frame )
+ break;
+ pViewFrame = SfxViewFrame::GetNext( *pViewFrame );
+ }
+ ENSURE_OR_RETURN( pViewFrame != NULL, "SfxModule::GetModuleFieldUnit: unable to find an SfxViewFrame for the given XFrame", FUNIT_100TH_MM );
+
+ // find the module
+ SfxModule const * pModule = GetActiveModule( pViewFrame );
+ ENSURE_OR_RETURN( pModule != NULL, "SfxModule::GetModuleFieldUnit: no SfxModule for the given frame!", FUNIT_100TH_MM );
+
+ SfxPoolItem const * pItem = pModule->GetItem( SID_ATTR_METRIC );
+ if ( pItem == NULL )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OStringBuffer message;
+ message.append( "SfxModule::GetFieldUnit: no metric item in the module implemented by '" );
+ message.append( typeid( *pModule ).name() );
+ message.append( "'!" );
+ OSL_ENSURE( false, message.makeStringAndClear().getStr() );
+#endif
+ return FUNIT_100TH_MM;
+ }
+ return (FieldUnit)( (SfxUInt16Item*)pItem )->GetValue();
+}
+
FieldUnit SfxModule::GetCurrentFieldUnit()
{
FieldUnit eUnit = FUNIT_INCH;
diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx
index e4862ae470e7..82e6afe883f5 100755
--- a/sfx2/source/doc/SfxDocumentMetaData.cxx
+++ b/sfx2/source/doc/SfxDocumentMetaData.cxx
@@ -1183,7 +1183,6 @@ void SAL_CALL SfxDocumentMetaData::init(
m_isInitialized = false;
m_xDoc = i_xDoc;
- m_xDoc->normalize();
// select nodes for standard meta data stuff
xPath->registerNS(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("xlink")),
@@ -1210,24 +1209,49 @@ void SAL_CALL SfxDocumentMetaData::init(
if (!m_xParent.is()) {
// all this create/append stuff may throw DOMException
try {
- css::uno::Reference<css::xml::dom::XElement> xRElem(
- i_xDoc->createElementNS(
+ css::uno::Reference<css::xml::dom::XElement> xRElem;
+ css::uno::Reference<css::xml::dom::XNode> xNode(
+ i_xDoc->getFirstChild());
+ while (xNode.is()) {
+ if (css::xml::dom::NodeType_ELEMENT_NODE ==xNode->getNodeType())
+ {
+ if (xNode->getNamespaceURI().equalsAscii(s_nsODF) &&
+ xNode->getLocalName().equalsAscii("document-meta"))
+ {
+ xRElem.set(xNode, css::uno::UNO_QUERY_THROW);
+ break;
+ }
+ else
+ {
+ OSL_TRACE("SfxDocumentMetaData::init(): "
+ "deleting unexpected root element: %s",
+ ::rtl::OUStringToOString(xNode->getLocalName(),
+ RTL_TEXTENCODING_UTF8).getStr());
+ i_xDoc->removeChild(xNode);
+ xNode = i_xDoc->getFirstChild(); // start over
+ }
+ } else {
+ xNode = xNode->getNextSibling();
+ }
+ }
+ if (!xRElem.is()) {
+ xRElem = i_xDoc->createElementNS(
::rtl::OUString::createFromAscii(s_nsODF),
- ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("office:document-meta"))));
- css::uno::Reference<css::xml::dom::XNode> xRNode(xRElem,
- css::uno::UNO_QUERY_THROW);
- // NB: the following is a _bad_idea_ with our DOM implementation
- // do _not_ create attributes with xmlns prefix!
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("office:document-meta")));
+ css::uno::Reference<css::xml::dom::XNode> xRNode(xRElem,
+ css::uno::UNO_QUERY_THROW);
+ i_xDoc->appendChild(xRNode);
+ }
xRElem->setAttributeNS(::rtl::OUString::createFromAscii(s_nsODF),
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("office:version")),
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1.0")));
- i_xDoc->appendChild(xRNode);
+ // does not exist, otherwise m_xParent would not be null
css::uno::Reference<css::xml::dom::XNode> xParent (
i_xDoc->createElementNS(
::rtl::OUString::createFromAscii(s_nsODF),
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("office:meta"))),
css::uno::UNO_QUERY_THROW);
- xRNode->appendChild(xParent);
+ xRElem->appendChild(xParent);
m_xParent = xParent;
} catch (css::xml::dom::DOMException & e) {
css::uno::Any a(e);
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index fc6856fdb083..5802606fb635 100755
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -938,11 +938,6 @@ void SfxObjectShell::SetCurrentComponent( const Reference< XInterface >& _rxComp
lcl_UpdateAppBasicDocVars( _rxComponent );
pAppMgr->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxComponent ) );
}
-
-#if OSL_DEBUG_LEVEL > 0
- const char* pComponentImplName = _rxComponent.get() ? typeid( *_rxComponent.get() ).name() : "void";
- OSL_TRACE( "current component is a %s\n", pComponentImplName );
-#endif
}
Reference< XInterface > SfxObjectShell::GetCurrentComponent()
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 4c02651073c2..3974e8aeeb81 100755
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -81,13 +81,15 @@ class SfxPrinterController : public vcl::PrinterController, public SfxListener
sal_Bool m_bOrigStatus;
sal_Bool m_bNeedsChange;
sal_Bool m_bApi;
+ sal_Bool m_bTempPrinter;
util::DateTime m_aLastPrinted;
::rtl::OUString m_aLastPrintedBy;
Sequence< beans::PropertyValue > getMergedOptions() const;
const Any& getSelectionObject() const;
public:
- SfxPrinterController( const Any& i_rComplete,
+ SfxPrinterController( const boost::shared_ptr<Printer>& i_rPrinter,
+ const Any& i_rComplete,
const Any& i_rSelection,
const Any& i_rViewProp,
const Reference< view::XRenderable >& i_xRender,
@@ -106,7 +108,8 @@ public:
virtual void jobFinished( com::sun::star::view::PrintableState );
};
-SfxPrinterController::SfxPrinterController( const Any& i_rComplete,
+SfxPrinterController::SfxPrinterController( const boost::shared_ptr<Printer>& i_rPrinter,
+ const Any& i_rComplete,
const Any& i_rSelection,
const Any& i_rViewProp,
const Reference< view::XRenderable >& i_xRender,
@@ -114,7 +117,8 @@ SfxPrinterController::SfxPrinterController( const Any& i_rComplete,
SfxViewShell* pView,
const uno::Sequence< beans::PropertyValue >& rProps
)
- : maCompleteSelection( i_rComplete )
+ : PrinterController( i_rPrinter)
+ , maCompleteSelection( i_rComplete )
, maSelection( i_rSelection )
, mxRenderable( i_xRender )
, mpLastPrinter( NULL )
@@ -123,6 +127,7 @@ SfxPrinterController::SfxPrinterController( const Any& i_rComplete,
, m_bOrigStatus( sal_False )
, m_bNeedsChange( sal_False )
, m_bApi(i_bApi)
+ , m_bTempPrinter( i_rPrinter.get() != NULL )
{
if ( mpViewShell )
{
@@ -192,15 +197,19 @@ SfxPrinterController::~SfxPrinterController()
const Any& SfxPrinterController::getSelectionObject() const
{
+ const beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelectionOnly" ) ) );
+ if( pVal )
+ {
+ sal_Bool bSel = sal_False;
+ pVal->Value >>= bSel;
+ return bSel ? maSelection : maCompleteSelection;
+ }
+
sal_Int32 nChoice = 0;
- sal_Bool bSel = sal_False;
- const beans::PropertyValue* pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) );
+ pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintContent" ) ) );
if( pVal )
pVal->Value >>= nChoice;
- pVal = getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelectionOnly" ) ) );
- if( pVal )
- pVal->Value >>= bSel;
- return (nChoice > 1 || bSel) ? maSelection : maCompleteSelection;
+ return (nChoice > 1) ? maSelection : maCompleteSelection;
}
Sequence< beans::PropertyValue > SfxPrinterController::getMergedOptions() const
@@ -308,6 +317,7 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt
{
if ( mpObjectShell )
{
+ bool bCopyJobSetup = false;
mpObjectShell->Broadcast( SfxPrintingHint( nState ) );
switch ( nState )
{
@@ -335,6 +345,7 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt
rBind.Invalidate( SID_PRINTDOC );
rBind.Invalidate( SID_PRINTDOCDIRECT );
rBind.Invalidate( SID_SETUPPRINTER );
+ bCopyJobSetup = ! m_bTempPrinter;
break;
}
@@ -342,6 +353,27 @@ void SfxPrinterController::jobFinished( com::sun::star::view::PrintableState nSt
break;
}
+ if( bCopyJobSetup && mpViewShell )
+ {
+ // #i114306#
+ // Note: this possibly creates a printer that gets immediately replaced
+ // by a new one. The reason for this is that otherwise we would not get
+ // the printer's SfxItemSet here to copy. Awkward, but at the moment there is no
+ // other way here to get the item set.
+ SfxPrinter* pDocPrt = mpViewShell->GetPrinter(sal_True);
+ if( pDocPrt )
+ {
+ if( pDocPrt->GetName() == getPrinter()->GetName() )
+ pDocPrt->SetJobSetup( getPrinter()->GetJobSetup() );
+ else
+ {
+ SfxPrinter* pNewPrt = new SfxPrinter( pDocPrt->GetOptions().Clone(), getPrinter()->GetName() );
+ pNewPrt->SetJobSetup( getPrinter()->GetJobSetup() );
+ mpViewShell->SetPrinter( pNewPrt, SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP );
+ }
+ }
+ }
+
if ( m_bNeedsChange )
mpObjectShell->EnableSetModified( m_bOrigStatus );
@@ -558,8 +590,23 @@ void SfxViewShell::ExecPrint( const uno::Sequence < beans::PropertyValue >& rPro
aSelection <<= GetObjectShell()->GetModel();
Any aComplete( makeAny( GetObjectShell()->GetModel() ) );
Any aViewProp( makeAny( xController ) );
+ boost::shared_ptr<Printer> aPrt;
- boost::shared_ptr<vcl::PrinterController> pController( new SfxPrinterController( aComplete,
+ const beans::PropertyValue* pVal = rProps.getConstArray();
+ for( sal_Int32 i = 0; i < rProps.getLength(); i++ )
+ {
+ if( pVal[i].Name.equalsAscii( "PrinterName" ) )
+ {
+ rtl::OUString aPrinterName;
+ pVal[i].Value >>= aPrinterName;
+ aPrt.reset( new Printer( aPrinterName ) );
+ break;
+ }
+ }
+
+ boost::shared_ptr<vcl::PrinterController> pController( new SfxPrinterController(
+ aPrt,
+ aComplete,
aSelection,
aViewProp,
GetRenderable(),
@@ -677,10 +724,18 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
}
}
}
- sal_Int32 nLen = aProps.getLength();
- aProps.realloc( nLen + 1 );
- aProps[nLen].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelectionOnly" ) );
- aProps[nLen].Value = makeAny( bSelection );
+ // HACK: writer sets the SID_SELECTION item when printing directly and expects
+ // to get only the selection document in that case (see getSelectionObject)
+ // however it also reacts to the PrintContent property. We need this distinction here, too,
+ // else one of the combinations print / print direct and selection / all will not work.
+ // it would be better if writer handled this internally
+ if( nId == SID_PRINTDOCDIRECT )
+ {
+ sal_Int32 nLen = aProps.getLength();
+ aProps.realloc( nLen + 1 );
+ aProps[nLen].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PrintSelectionOnly" ) );
+ aProps[nLen].Value = makeAny( bSelection );
+ }
ExecPrint( aProps, bIsAPI, (nId == SID_PRINTDOCDIRECT) );