2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-21 22:06:52 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-09-01 20:30:52 +01:00
|
|
|
#include <svx/XPropertyTable.hxx>
|
|
|
|
#include "xmlxtexp.hxx"
|
|
|
|
#include "xmlxtimp.hxx"
|
|
|
|
#include <tools/urlobj.hxx>
|
2007-06-27 18:36:29 +00:00
|
|
|
#include <svx/xtable.hxx>
|
|
|
|
#include <svx/xpool.hxx>
|
2013-04-10 08:20:16 +00:00
|
|
|
#include <svx/svdobj.hxx>
|
|
|
|
#include <svx/svdpool.hxx>
|
2015-08-31 20:33:37 -04:00
|
|
|
#include <vcl/outdev.hxx>
|
2015-06-06 14:24:46 +01:00
|
|
|
#include <stack>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-09-01 20:30:52 +01:00
|
|
|
using namespace com::sun::star;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-09-05 17:22:24 +01:00
|
|
|
// Helper for other sub-classes to have easy-to-read constructors
|
2000-09-18 16:07:07 +00:00
|
|
|
Color RGB_Color( ColorData nColorName )
|
|
|
|
{
|
|
|
|
Color aColor( nColorName );
|
|
|
|
Color aRGBColor( aColor.GetRed(), aColor.GetGreen(), aColor.GetBlue() );
|
|
|
|
return aRGBColor;
|
|
|
|
}
|
|
|
|
|
2013-08-29 14:32:14 +02:00
|
|
|
XColorEntry::XColorEntry(const Color& rColor, const OUString& rName)
|
2013-05-02 13:22:17 +00:00
|
|
|
: XPropertyEntry(rName),
|
|
|
|
aColor(rColor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XColorEntry::XColorEntry(const XColorEntry& rOther)
|
|
|
|
: XPropertyEntry(rOther),
|
|
|
|
aColor(rOther.aColor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-29 14:32:14 +02:00
|
|
|
XLineEndEntry::XLineEndEntry(const basegfx::B2DPolyPolygon& rB2DPolyPolygon, const OUString& rName)
|
2013-05-02 13:22:17 +00:00
|
|
|
: XPropertyEntry(rName),
|
|
|
|
aB2DPolyPolygon(rB2DPolyPolygon)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XLineEndEntry::XLineEndEntry(const XLineEndEntry& rOther)
|
|
|
|
: XPropertyEntry(rOther),
|
|
|
|
aB2DPolyPolygon(rOther.aB2DPolyPolygon)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-29 14:32:14 +02:00
|
|
|
XDashEntry::XDashEntry(const XDash& rDash, const OUString& rName)
|
2013-05-02 13:22:17 +00:00
|
|
|
: XPropertyEntry(rName),
|
|
|
|
aDash(rDash)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XDashEntry::XDashEntry(const XDashEntry& rOther)
|
|
|
|
: XPropertyEntry(rOther),
|
|
|
|
aDash(rOther.aDash)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-29 14:32:14 +02:00
|
|
|
XHatchEntry::XHatchEntry(const XHatch& rHatch, const OUString& rName)
|
2013-05-02 13:22:17 +00:00
|
|
|
: XPropertyEntry(rName),
|
|
|
|
aHatch(rHatch)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XHatchEntry::XHatchEntry(const XHatchEntry& rOther)
|
|
|
|
: XPropertyEntry(rOther),
|
|
|
|
aHatch(rOther.aHatch)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-29 14:32:14 +02:00
|
|
|
XGradientEntry::XGradientEntry(const XGradient& rGradient, const OUString& rName)
|
2013-05-02 13:22:17 +00:00
|
|
|
: XPropertyEntry(rName),
|
|
|
|
aGradient(rGradient)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XGradientEntry::XGradientEntry(const XGradientEntry& rOther)
|
|
|
|
: XPropertyEntry(rOther),
|
|
|
|
aGradient(rOther.aGradient)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-08-29 14:32:14 +02:00
|
|
|
XBitmapEntry::XBitmapEntry(const GraphicObject& rGraphicObject, const OUString& rName)
|
2013-05-02 13:22:17 +00:00
|
|
|
: XPropertyEntry(rName),
|
|
|
|
maGraphicObject(rGraphicObject)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XBitmapEntry::XBitmapEntry(const XBitmapEntry& rOther)
|
|
|
|
: XPropertyEntry(rOther),
|
|
|
|
maGraphicObject(rOther.maGraphicObject)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-06-19 21:27:48 -07:00
|
|
|
XPropertyList::XPropertyList(
|
2011-09-05 17:22:24 +01:00
|
|
|
XPropertyListType type,
|
rhbz#887420 Implement "block untrusted referer links" feature
For now, this checks for a trusted referer (if the BlockUntrustedRefererLinks
configuration prop is set) in utl::MediaDescriptor::impl_openStreamWithURL and
SvxBrushItem::GetGraphicObject. Checking in additional places will probably be
necessary to block /all/ unwanted communication. Also, some places marked
/*TODO?*/ currently pass in an empty referer (which is always considered
trusted) and will probably need to be adapted.
Ideally, Referer URIs would never be empty (and consistently use something like
<private:user> for cases where access is explicitly initiated by the user and
should never be blocked), but that's a very daunting task, so start small by
identifying the places that potentially need blocking and adding appropriate
Referer URIs there. Also, Referer information should always be computed as
freshly as possible from the context in which an access attempt is made, but,
again, always carrying the information from the context all the way to the
relevant functions is a very daunting task, so for now store the information
upon object instantiation in some cases (SvxBrushItem, SdrGrafObj, ...).
The Referer URI (css.document.MediaDescriptor property; SID_REFERER) was already
used to track macro execution, and there is one place in
SfxApplication::OpenDocExec_Impl where opening of hyperlinks (explicitly clicked
by the user) is done that needs the current document's URI as Referer to check
execution of macro URIs but needs an empty (or <private:user>, see above)
Referer to not block non-macro URIs. Special code has been added there to
handle that.
Change-Id: Iafbdc07a9fe925d9ee580d4f5778448f18f2ebd9
2013-11-14 10:39:27 +01:00
|
|
|
const OUString& rPath, const OUString& rReferer
|
2013-04-10 08:20:16 +00:00
|
|
|
) : meType ( type ),
|
2013-11-14 13:13:19 +02:00
|
|
|
maName ( "standard" ),
|
2013-04-10 08:20:16 +00:00
|
|
|
maPath ( rPath ),
|
rhbz#887420 Implement "block untrusted referer links" feature
For now, this checks for a trusted referer (if the BlockUntrustedRefererLinks
configuration prop is set) in utl::MediaDescriptor::impl_openStreamWithURL and
SvxBrushItem::GetGraphicObject. Checking in additional places will probably be
necessary to block /all/ unwanted communication. Also, some places marked
/*TODO?*/ currently pass in an empty referer (which is always considered
trusted) and will probably need to be adapted.
Ideally, Referer URIs would never be empty (and consistently use something like
<private:user> for cases where access is explicitly initiated by the user and
should never be blocked), but that's a very daunting task, so start small by
identifying the places that potentially need blocking and adding appropriate
Referer URIs there. Also, Referer information should always be computed as
freshly as possible from the context in which an access attempt is made, but,
again, always carrying the information from the context all the way to the
relevant functions is a very daunting task, so for now store the information
upon object instantiation in some cases (SvxBrushItem, SdrGrafObj, ...).
The Referer URI (css.document.MediaDescriptor property; SID_REFERER) was already
used to track macro execution, and there is one place in
SfxApplication::OpenDocExec_Impl where opening of hyperlinks (explicitly clicked
by the user) is done that needs the current document's URI as Referer to check
execution of macro URIs but needs an empty (or <private:user>, see above)
Referer to not block non-macro URIs. Special code has been added there to
handle that.
Change-Id: Iafbdc07a9fe925d9ee580d4f5778448f18f2ebd9
2013-11-14 10:39:27 +01:00
|
|
|
maReferer ( rReferer ),
|
2013-04-10 08:20:16 +00:00
|
|
|
mbListDirty ( true ),
|
|
|
|
mbEmbedInDocument( false )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
// fprintf (stderr, "Create type %d count %d\n", (int)meType, count++);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XPropertyList::~XPropertyList()
|
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
// fprintf (stderr, "Destroy type %d count %d\n", (int)meType, --count);
|
|
|
|
for( size_t i = 0, n = maList.size(); i < n; ++i )
|
|
|
|
delete maList[ i ];
|
2011-09-23 14:05:07 +01:00
|
|
|
|
2013-04-10 08:20:16 +00:00
|
|
|
maList.clear();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
long XPropertyList::Count() const
|
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
if( mbListDirty )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-03-26 15:31:47 +01:00
|
|
|
if( !const_cast<XPropertyList*>(this)->Load() )
|
|
|
|
const_cast<XPropertyList*>(this)->Create();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2013-04-10 08:20:16 +00:00
|
|
|
return maList.size();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-05-02 13:22:17 +00:00
|
|
|
XPropertyEntry* XPropertyList::Get( long nIndex ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
if( mbListDirty )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-03-26 15:31:47 +01:00
|
|
|
if( !const_cast<XPropertyList*>(this)->Load() )
|
|
|
|
const_cast<XPropertyList*>(this)->Create();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2013-04-10 08:20:16 +00:00
|
|
|
return ( (size_t)nIndex < maList.size() ) ? maList[ nIndex ] : NULL;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-09-03 13:30:35 +01:00
|
|
|
long XPropertyList::GetIndex(const OUString& rName) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
if( mbListDirty )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-03-26 15:31:47 +01:00
|
|
|
if( !const_cast<XPropertyList*>(this)->Load() )
|
|
|
|
const_cast<XPropertyList*>(this)->Create();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2011-06-19 21:27:48 -07:00
|
|
|
|
2013-04-10 08:20:16 +00:00
|
|
|
for( long i = 0, n = maList.size(); i < n; ++i ) {
|
2013-09-03 13:30:35 +01:00
|
|
|
if (rName.equals(maList[ i ]->GetName())) {
|
2011-06-19 21:27:48 -07:00
|
|
|
return i;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2011-06-19 21:27:48 -07:00
|
|
|
return -1;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-04-10 08:20:16 +00:00
|
|
|
Bitmap XPropertyList::GetUiBitmap( long nIndex ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
Bitmap aRetval;
|
|
|
|
XPropertyEntry* pEntry = ( (size_t)nIndex < maList.size() ) ? maList[ nIndex ] : NULL;
|
|
|
|
if(pEntry)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
aRetval = pEntry->GetUiBitmap();
|
|
|
|
|
|
|
|
if(aRetval.IsEmpty())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
aRetval = const_cast< XPropertyList* >(this)->CreateBitmapForUI(nIndex);
|
|
|
|
pEntry->SetUiBitmap(aRetval);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-10 08:20:16 +00:00
|
|
|
return aRetval;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XPropertyList::Insert( XPropertyEntry* pEntry, long nIndex )
|
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
if ( (size_t)nIndex < maList.size() ) {
|
|
|
|
maList.insert( maList.begin() + nIndex, pEntry );
|
2011-06-19 21:27:48 -07:00
|
|
|
} else {
|
2013-04-10 08:20:16 +00:00
|
|
|
maList.push_back( pEntry );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
XPropertyEntry* XPropertyList::Replace( XPropertyEntry* pEntry, long nIndex )
|
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
XPropertyEntry* pOldEntry = (size_t)nIndex < maList.size() ? maList[ nIndex ] : NULL;
|
2011-06-19 21:27:48 -07:00
|
|
|
if ( pOldEntry ) {
|
2013-04-10 08:20:16 +00:00
|
|
|
maList[ nIndex ] = pEntry;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
return pOldEntry;
|
|
|
|
}
|
|
|
|
|
2011-06-21 07:29:15 -07:00
|
|
|
XPropertyEntry* XPropertyList::Remove( long nIndex )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2011-06-19 21:27:48 -07:00
|
|
|
XPropertyEntry* pEntry = NULL;
|
2013-04-10 08:20:16 +00:00
|
|
|
if ( (size_t)nIndex < maList.size() ) {
|
|
|
|
pEntry = maList[ nIndex ];
|
|
|
|
maList.erase( maList.begin() + nIndex );
|
2011-06-19 21:27:48 -07:00
|
|
|
}
|
|
|
|
return pEntry;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-29 14:32:14 +02:00
|
|
|
void XPropertyList::SetName( const OUString& rString )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-08-29 14:32:14 +02:00
|
|
|
if(!rString.isEmpty())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
maName = rString;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-10 14:47:28 +01:00
|
|
|
bool XPropertyList::Load()
|
2011-09-01 20:30:52 +01:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
if( mbListDirty )
|
2011-09-01 20:30:52 +01:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
mbListDirty = false;
|
2015-06-06 14:24:46 +01:00
|
|
|
std::stack<OUString> aDirs;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-06-06 14:24:46 +01:00
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
do
|
2011-09-01 20:30:52 +01:00
|
|
|
{
|
2015-06-06 14:24:46 +01:00
|
|
|
aDirs.push(maPath.getToken(0, ';', nIndex));
|
2011-09-01 20:30:52 +01:00
|
|
|
}
|
2015-06-06 14:24:46 +01:00
|
|
|
while (nIndex >= 0);
|
|
|
|
|
|
|
|
//try all entries palette path list working back to front until one
|
|
|
|
//succeeds
|
|
|
|
while (!aDirs.empty())
|
|
|
|
{
|
|
|
|
OUString aPath(aDirs.top());
|
|
|
|
aDirs.pop();
|
|
|
|
|
|
|
|
INetURLObject aURL(aPath);
|
|
|
|
|
|
|
|
if( INetProtocol::NotValid == aURL.GetProtocol() )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( aPath.isEmpty(), "invalid URL" );
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-01 20:30:52 +01:00
|
|
|
|
2015-06-06 14:24:46 +01:00
|
|
|
aURL.Append( maName );
|
2011-09-01 20:30:52 +01:00
|
|
|
|
2015-06-06 14:24:46 +01:00
|
|
|
if( aURL.getExtension().isEmpty() )
|
|
|
|
aURL.setExtension( GetDefaultExt() );
|
2011-09-01 20:30:52 +01:00
|
|
|
|
2015-06-06 14:24:46 +01:00
|
|
|
bool bRet = SvxXMLXTableImport::load(aURL.GetMainURL(INetURLObject::NO_DECODE),
|
|
|
|
maReferer, uno::Reference < embed::XStorage >(),
|
|
|
|
createInstance(), NULL );
|
|
|
|
if (bRet)
|
|
|
|
return bRet;
|
|
|
|
}
|
2011-09-01 20:30:52 +01:00
|
|
|
}
|
2011-09-10 14:47:28 +01:00
|
|
|
return false;
|
2011-09-01 20:30:52 +01:00
|
|
|
}
|
|
|
|
|
2011-09-10 14:47:28 +01:00
|
|
|
bool XPropertyList::LoadFrom( const uno::Reference < embed::XStorage > &xStorage,
|
rhbz#887420 Implement "block untrusted referer links" feature
For now, this checks for a trusted referer (if the BlockUntrustedRefererLinks
configuration prop is set) in utl::MediaDescriptor::impl_openStreamWithURL and
SvxBrushItem::GetGraphicObject. Checking in additional places will probably be
necessary to block /all/ unwanted communication. Also, some places marked
/*TODO?*/ currently pass in an empty referer (which is always considered
trusted) and will probably need to be adapted.
Ideally, Referer URIs would never be empty (and consistently use something like
<private:user> for cases where access is explicitly initiated by the user and
should never be blocked), but that's a very daunting task, so start small by
identifying the places that potentially need blocking and adding appropriate
Referer URIs there. Also, Referer information should always be computed as
freshly as possible from the context in which an access attempt is made, but,
again, always carrying the information from the context all the way to the
relevant functions is a very daunting task, so for now store the information
upon object instantiation in some cases (SvxBrushItem, SdrGrafObj, ...).
The Referer URI (css.document.MediaDescriptor property; SID_REFERER) was already
used to track macro execution, and there is one place in
SfxApplication::OpenDocExec_Impl where opening of hyperlinks (explicitly clicked
by the user) is done that needs the current document's URI as Referer to check
execution of macro URIs but needs an empty (or <private:user>, see above)
Referer to not block non-macro URIs. Special code has been added there to
handle that.
Change-Id: Iafbdc07a9fe925d9ee580d4f5778448f18f2ebd9
2013-11-14 10:39:27 +01:00
|
|
|
const OUString &rURL, const OUString &rReferer )
|
2011-09-10 14:47:28 +01:00
|
|
|
{
|
2013-04-10 08:20:16 +00:00
|
|
|
if( !mbListDirty )
|
2011-09-10 14:47:28 +01:00
|
|
|
return false;
|
2013-04-10 08:20:16 +00:00
|
|
|
mbListDirty = false;
|
rhbz#887420 Implement "block untrusted referer links" feature
For now, this checks for a trusted referer (if the BlockUntrustedRefererLinks
configuration prop is set) in utl::MediaDescriptor::impl_openStreamWithURL and
SvxBrushItem::GetGraphicObject. Checking in additional places will probably be
necessary to block /all/ unwanted communication. Also, some places marked
/*TODO?*/ currently pass in an empty referer (which is always considered
trusted) and will probably need to be adapted.
Ideally, Referer URIs would never be empty (and consistently use something like
<private:user> for cases where access is explicitly initiated by the user and
should never be blocked), but that's a very daunting task, so start small by
identifying the places that potentially need blocking and adding appropriate
Referer URIs there. Also, Referer information should always be computed as
freshly as possible from the context in which an access attempt is made, but,
again, always carrying the information from the context all the way to the
relevant functions is a very daunting task, so for now store the information
upon object instantiation in some cases (SvxBrushItem, SdrGrafObj, ...).
The Referer URI (css.document.MediaDescriptor property; SID_REFERER) was already
used to track macro execution, and there is one place in
SfxApplication::OpenDocExec_Impl where opening of hyperlinks (explicitly clicked
by the user) is done that needs the current document's URI as Referer to check
execution of macro URIs but needs an empty (or <private:user>, see above)
Referer to not block non-macro URIs. Special code has been added there to
handle that.
Change-Id: Iafbdc07a9fe925d9ee580d4f5778448f18f2ebd9
2013-11-14 10:39:27 +01:00
|
|
|
return SvxXMLXTableImport::load( rURL, rReferer, xStorage, createInstance(), &mbEmbedInDocument );
|
2011-09-10 14:47:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool XPropertyList::Save()
|
2011-09-01 20:30:52 +01:00
|
|
|
{
|
2015-06-06 14:24:46 +01:00
|
|
|
//save to the last path in the palette path list
|
|
|
|
OUString aLastDir;
|
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
aLastDir = maPath.getToken(0, ';', nIndex);
|
|
|
|
}
|
|
|
|
while (nIndex >= 0);
|
|
|
|
|
|
|
|
INetURLObject aURL(aLastDir);
|
2011-09-01 20:30:52 +01:00
|
|
|
|
2015-04-02 18:32:36 +02:00
|
|
|
if( INetProtocol::NotValid == aURL.GetProtocol() )
|
2011-09-01 20:30:52 +01:00
|
|
|
{
|
2015-06-06 14:24:46 +01:00
|
|
|
DBG_ASSERT( aLastDir.isEmpty(), "invalid URL" );
|
2011-09-10 14:47:28 +01:00
|
|
|
return false;
|
2011-09-01 20:30:52 +01:00
|
|
|
}
|
|
|
|
|
2013-04-10 08:20:16 +00:00
|
|
|
aURL.Append( maName );
|
2011-09-01 20:30:52 +01:00
|
|
|
|
2012-01-14 12:10:39 -02:00
|
|
|
if( aURL.getExtension().isEmpty() )
|
2011-09-28 10:42:36 +01:00
|
|
|
aURL.setExtension( GetDefaultExt() );
|
2011-09-01 20:30:52 +01:00
|
|
|
|
2011-09-10 14:47:28 +01:00
|
|
|
return SvxXMLXTableExportComponent::save( aURL.GetMainURL( INetURLObject::NO_DECODE ),
|
|
|
|
createInstance(),
|
|
|
|
uno::Reference< embed::XStorage >(), NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool XPropertyList::SaveTo( const uno::Reference< embed::XStorage > &xStorage,
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString &rURL, OUString *pOptName )
|
2011-09-10 14:47:28 +01:00
|
|
|
{
|
|
|
|
return SvxXMLXTableExportComponent::save( rURL, createInstance(), xStorage, pOptName );
|
2011-09-01 20:30:52 +01:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-07-31 19:59:20 +09:00
|
|
|
XPropertyListRef XPropertyList::CreatePropertyList( XPropertyListType aType,
|
rhbz#887420 Implement "block untrusted referer links" feature
For now, this checks for a trusted referer (if the BlockUntrustedRefererLinks
configuration prop is set) in utl::MediaDescriptor::impl_openStreamWithURL and
SvxBrushItem::GetGraphicObject. Checking in additional places will probably be
necessary to block /all/ unwanted communication. Also, some places marked
/*TODO?*/ currently pass in an empty referer (which is always considered
trusted) and will probably need to be adapted.
Ideally, Referer URIs would never be empty (and consistently use something like
<private:user> for cases where access is explicitly initiated by the user and
should never be blocked), but that's a very daunting task, so start small by
identifying the places that potentially need blocking and adding appropriate
Referer URIs there. Also, Referer information should always be computed as
freshly as possible from the context in which an access attempt is made, but,
again, always carrying the information from the context all the way to the
relevant functions is a very daunting task, so for now store the information
upon object instantiation in some cases (SvxBrushItem, SdrGrafObj, ...).
The Referer URI (css.document.MediaDescriptor property; SID_REFERER) was already
used to track macro execution, and there is one place in
SfxApplication::OpenDocExec_Impl where opening of hyperlinks (explicitly clicked
by the user) is done that needs the current document's URI as Referer to check
execution of macro URIs but needs an empty (or <private:user>, see above)
Referer to not block non-macro URIs. Special code has been added there to
handle that.
Change-Id: Iafbdc07a9fe925d9ee580d4f5778448f18f2ebd9
2013-11-14 10:39:27 +01:00
|
|
|
const OUString& rPath,
|
|
|
|
const OUString& rReferer )
|
2011-09-05 17:22:24 +01:00
|
|
|
{
|
2011-09-23 14:05:07 +01:00
|
|
|
XPropertyListRef pRet;
|
2011-09-05 17:22:24 +01:00
|
|
|
|
2015-07-31 19:59:20 +09:00
|
|
|
switch (aType) {
|
|
|
|
case XCOLOR_LIST:
|
|
|
|
pRet = XPropertyListRef(new XColorList(rPath, rReferer));
|
|
|
|
break;
|
|
|
|
case XLINE_END_LIST:
|
|
|
|
pRet = XPropertyListRef(new XLineEndList(rPath, rReferer));
|
|
|
|
break;
|
|
|
|
case XDASH_LIST:
|
|
|
|
pRet = XPropertyListRef(new XDashList(rPath, rReferer));
|
|
|
|
break;
|
|
|
|
case XHATCH_LIST:
|
|
|
|
pRet = XPropertyListRef(new XHatchList(rPath, rReferer));
|
|
|
|
break;
|
|
|
|
case XGRADIENT_LIST:
|
|
|
|
pRet = XPropertyListRef(new XGradientList(rPath, rReferer));
|
|
|
|
break;
|
|
|
|
case XBITMAP_LIST:
|
|
|
|
pRet = XPropertyListRef(new XBitmapList(rPath, rReferer));
|
|
|
|
break;
|
2011-09-05 17:22:24 +01:00
|
|
|
default:
|
|
|
|
OSL_FAIL("unknown xproperty type");
|
|
|
|
break;
|
|
|
|
}
|
2015-07-31 19:59:20 +09:00
|
|
|
OSL_ASSERT( !pRet.is() || pRet->meType == aType );
|
2011-09-05 17:22:24 +01:00
|
|
|
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2011-09-28 09:08:44 +01:00
|
|
|
XPropertyListRef
|
|
|
|
XPropertyList::CreatePropertyListFromURL( XPropertyListType t,
|
2013-06-18 10:07:44 +01:00
|
|
|
const OUString & rURLStr )
|
2011-09-28 09:08:44 +01:00
|
|
|
{
|
|
|
|
INetURLObject aURL( rURLStr );
|
|
|
|
INetURLObject aPathURL( aURL );
|
|
|
|
|
|
|
|
aPathURL.removeSegment();
|
|
|
|
aPathURL.removeFinalSlash();
|
|
|
|
|
|
|
|
XPropertyListRef pList = XPropertyList::CreatePropertyList(
|
rhbz#887420 Implement "block untrusted referer links" feature
For now, this checks for a trusted referer (if the BlockUntrustedRefererLinks
configuration prop is set) in utl::MediaDescriptor::impl_openStreamWithURL and
SvxBrushItem::GetGraphicObject. Checking in additional places will probably be
necessary to block /all/ unwanted communication. Also, some places marked
/*TODO?*/ currently pass in an empty referer (which is always considered
trusted) and will probably need to be adapted.
Ideally, Referer URIs would never be empty (and consistently use something like
<private:user> for cases where access is explicitly initiated by the user and
should never be blocked), but that's a very daunting task, so start small by
identifying the places that potentially need blocking and adding appropriate
Referer URIs there. Also, Referer information should always be computed as
freshly as possible from the context in which an access attempt is made, but,
again, always carrying the information from the context all the way to the
relevant functions is a very daunting task, so for now store the information
upon object instantiation in some cases (SvxBrushItem, SdrGrafObj, ...).
The Referer URI (css.document.MediaDescriptor property; SID_REFERER) was already
used to track macro execution, and there is one place in
SfxApplication::OpenDocExec_Impl where opening of hyperlinks (explicitly clicked
by the user) is done that needs the current document's URI as Referer to check
execution of macro URIs but needs an empty (or <private:user>, see above)
Referer to not block non-macro URIs. Special code has been added there to
handle that.
Change-Id: Iafbdc07a9fe925d9ee580d4f5778448f18f2ebd9
2013-11-14 10:39:27 +01:00
|
|
|
t, aPathURL.GetMainURL( INetURLObject::NO_DECODE ), "" );
|
2011-09-28 09:08:44 +01:00
|
|
|
pList->SetName( aURL.getName() );
|
|
|
|
|
|
|
|
return pList;
|
|
|
|
}
|
|
|
|
|
2011-09-23 14:05:07 +01:00
|
|
|
// catch people being silly with ref counting ...
|
|
|
|
|
|
|
|
void* XPropertyList::operator new (size_t nCount)
|
|
|
|
{
|
|
|
|
return rtl_allocateMemory( nCount );
|
|
|
|
}
|
|
|
|
|
|
|
|
void XPropertyList::operator delete(void *pPtr)
|
|
|
|
{
|
|
|
|
return rtl_freeMemory( pPtr );
|
|
|
|
}
|
|
|
|
|
2011-09-28 09:08:44 +01:00
|
|
|
static struct {
|
|
|
|
XPropertyListType t;
|
|
|
|
const char *pExt;
|
|
|
|
} pExtnMap[] = {
|
|
|
|
{ XCOLOR_LIST, "soc" },
|
|
|
|
{ XLINE_END_LIST, "soe" },
|
|
|
|
{ XDASH_LIST, "sod" },
|
|
|
|
{ XHATCH_LIST, "soh" },
|
|
|
|
{ XGRADIENT_LIST, "sog" },
|
|
|
|
{ XBITMAP_LIST, "sob" }
|
|
|
|
};
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString XPropertyList::GetDefaultExt( XPropertyListType t )
|
2011-09-28 09:08:44 +01:00
|
|
|
{
|
|
|
|
for (size_t i = 0; i < SAL_N_ELEMENTS (pExtnMap); i++)
|
|
|
|
{
|
|
|
|
if( pExtnMap[i].t == t )
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString::createFromAscii( pExtnMap[ i ].pExt );
|
2011-09-28 09:08:44 +01:00
|
|
|
}
|
2013-04-07 12:06:47 +02:00
|
|
|
return OUString();
|
2011-09-28 09:08:44 +01:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString XPropertyList::GetDefaultExtFilter( XPropertyListType t )
|
2011-09-28 09:08:44 +01:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aFilter( "*." );
|
2011-09-28 09:08:44 +01:00
|
|
|
return aFilter + GetDefaultExt( t );
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|